I need a list of the AD groups for a user

I need a list of the AD groups for a user , I am getting the error Get-ADPrincipalGroupMembership : Unable to find a default server with Active Directory Web Services running.
At line:1 char:1

  • Get-ADPrincipalGroupMembership $username | select name,SamAccountname …
  •   + CategoryInfo          : ResourceUnavailable: (:) [Get-ADPrincipalGroupMembership], ADServerDownException
      + FullyQualifiedErrorId : ActiveDirectoryServer:1355,Microsoft.ActiveDirectory.Management.Commands.GetADPrincipalG
     roupMembership

You’re trying to use a positional parameter by just providing the name and not specifying which param it goes to. Have you tried using the “Identity” parameter before the name?

Get-ADPrincipalGroupMembership -Identity USERID | Select-Object Name

Sorry don’t use PS much: PS C:\Windows\system32> Get-ADPrincipalGroupMembership -Identity USERID | Select-Object Name
Get-ADPrincipalGroupMembership : Unable to find a default server with Active Directory Web Services running.
At line:1 char:1

  • Get-ADPrincipalGroupMembership -Identity USERID | Select-Object Name
  •   + CategoryInfo          : ResourceUnavailable: (:) [Get-ADPrincipalGroupMembership], ADServerDownException
      + FullyQualifiedErrorId : ActiveDirectoryServer:1355,Microsoft.ActiveDirectory.Management.Commands.GetADPrincipalG
     roupMembership
    
    

PS C:\Windows\system32>

The error makes it sound like you aren’t running the command on a domain-joined computer, or you can’t access a domain controller for some other reason. Are you part of an on-premises domain or an Azure AD (Entra ID) domain?

If you know the name of a domain controller or some other system running Active Directory Web Services, you can specify that on the command:

Get-ADPrincipalGroupMembership -Server <domain controller FQDN or IP> -Identity <username> | Select-Object name

(Get-ADUser n***** -Server ad –Properties MemberOf).MemberOf | %{(($_ -split “=”)[1] -split “,”)[0]} | sort

worked thanks