Import-Module ActiveDirectory
Get-ADObject -Filter {ObjectClass -eq "msDS-GroupManagedServiceAccount" -and Name -Like '*SomeGmsa*' } -Properties DistinguishedName, SamAccountName | Select DistinguishedName, SamAccountName
This yields the results:
DistinguishedName SamAccountName
----------------- --------------
CN=gMSA1DVSomeGmsa,CN=Managed Service Accounts,DC=someacme,DC=org MSA1DVSomeAcmeP$
CN=gMSA1_gMSA1DGmsaPT,CN=Managed Service Accounts,DC=someacme,DC=org MSA1gMSA1DVSomeAcme$
CN=gMSA1_DVSomeGmsaPT,CN=Managed Service Accounts,DC=someacme,DC=org MSA1DVSomeAcmePT$
You can search for gMSA users in AD like this:
Import-Module ActiveDirectory
Get-ADServiceAccount -Filter "Name -like '*SomeGmsa*'"
This should yield a list of matching gMSA users with given name :
You can also ask for all properties of Gmsa users using -Properties with * :
Import-Module ActiveDirectory
Get-ADObject -Filter {ObjectClass -eq "msDS-GroupManagedServiceAccount" -and Name -Like '*SomeGmsa*' } -Properties *
No comments:
Post a Comment