OpsaC - Operating as PowerShell code
published: November 10, 2020 author: Tinu tags: PowerShell categories: PowerShell-Active-Directory
The Get-ADPrincipalGroupMembership cmdlet gets the Active Directory groups that have a specified user, computer, group, or service account as a member. This cmdlet requires a global catalog to perform the group search. If the forest that contains the user, computer, or group does not have a global catalog, the cmdlet returns a non-terminating error.
@{$($env:USERNAME)=(Get-ADPrincipalGroupMembership -Identity $env:USERNAME | Select -ExpandProperty Name)}
Name Value
---- -----
MyAccount {Domain Users, Remote Desktop Users}
Get-ADPrincipalGroupMembership on Microsoft Docs.