A short article with tips how you can find gMSA accounts in Active Directory or AD.
First off, import the module ActiveDirectory.
Then you can run the following snippet to find some gMsa accounts of which you know part of the name of.
Please note that your server should also install the gMsa account where it shall be used ! And to use the module ActiveDirectory, the Windows feature must be installed.
From Powershell admin console you can run:
# Remember to install the RSAT-AD-Powershell module
Add-WindowsFeature RSAT-AD-PowerShell
Install-ADServiceAccount SomeGmsa$
Import-Module ActiveDirectory
Get-ADObject -Filter {ObjectClass -eq "msDS-GroupManagedServiceAccount" -and Name -Like '*SomeGmsa*' } -Properties DistinguishedName, SamAccountName | Select DistinguishedName, SamAccountName
Note that you gMsa user has a SamAccountName which is suffixed by '$'. This can be set up in IIS for you application as the app pool identity. The username will be in this example:
MYDOMAIN\SomeGmsa$
The password of the gMSa service account will actually be empty ! Instead, the service account is installed as shown above using the cmd-let Install-AdServiceAccount.
The following powershell script defines some functions in Powershell that can start up or stop all iis app pools on a server. It can be handy when you want to
test out concurrency issues and switch off all IIS app pools and start up again.
Function fnStartApplicationPool([string]$appPoolName){
Import-Module WebAdministration
if ((Get-WebAppPoolState $appPoolName).Value -ne 'Started') {
Write-Host 'IIS app pool ' $appPoolName ' is not started. Starting.'
Start-WebAppPool -Name $appPoolName
Write-Host 'IIS app pool ' $appPoolName 'started'
}
}
Function fnStartAllApplicationPools() {
Import-Module WebAdministration
Write-Host "Starting all app pools"
$appPools = (Get-ChildItem IIS:\AppPools)
foreach ($appPool in $appPools) {
& fnStartApplicationPool -appPoolName $appPool.Name
}
}
#fnStartAllApplicationPools #start all applications pools
Function fnStopApplicationPool([string]$poolname) {
Import-Module WebAdministration
if ((Get-WebAppPoolState $appPoolName).Value -ne 'Stopped') {
Stop-WebAppPool -Name $appPoolName
}
}
Function fnStopAllApplicationPools(){
Import-Module WebAdministration
Write-Host "Starting all app pools"
$appPools = (Get-ChildItem IIS:\AppPools)
foreach ($appPool in $appPools) {
& fnStopApplicationPool-appPoolName $appPool.Name
}
}
#fnStopAllApplicationPools #start all applications pools
I am working with a solution at work where I need to enable IIS Client certificates. I am not able to get past the "Provide client certificate" dialog, but
it is possible to alter the setup of SSL cert bindings on your computer through the Netsh command. This command is not in Powershell, but at the command line.
I decided to write some Powershell functions to be able to alter this setup atleast in an easier way. One annoyance with the netsh command is that you have to keep track of the
Application Id and Certificate hash values. Here, we can easier keep track of this through Powershell code.
The Powershell code to display and alter, modify, delete and and SSL cert bindings is as follows: