How to get all Active Directory groups of an user with powershell?

Von Published On: Oktober 19th, 2026

Ein kurzer Überblick über die in diesem Artikel behandelten Themen.

How to get all Active Directory groups of an user

Sometimes it is needed to get all the Active Directory groups for an user. One reason is the calculation of KERBEROS TOKEN size for an user.

On the web are a lot of articles exists where you can see that it is solved with just 3 lines, but it never works fine:

$samAccountName = "a.azubi"
$username = $samAccountName
$dn = (Get-ADUser $username).DistinguishedName
Get-ADGroup -LDAPFilter ("(member:1.2.840.113556.1.4.1941:=)" -f $dn) | select -expand Name | sort Name

During the use of your CARO-Suite Account View you can see that the number and amount of membership is not true.

Here is the output of the command in our environment:

Get-AllGroups1_Script_Output

(Screenshot property of ©Microsoft 2020)

How are group memberships displayed in the CARO Suite?

But in the CARO-Suite tool you see:

CARO_AllGroups

(CARO-Kontenansicht: Anzahl an Gruppenmitgliedschaften)

As you can see the number is 32 AD Groups + 1 (local group membership of a Windows PC). This is a benefit of the CARO-Suite, that you can see the membership of any device or technology you connected with collectors. The PowerShell command gives us just 26 AD Groups and this makes a difference of 6 AD groups.

Differnce_between_the_calls

(Notepad++ Fenster: Vergleich der beiden Ausgaben)

The complete powershell script to get all groups

We’ve adapted the command and then it shows all what the CARO-Suite shows.

Script Part 1
Script Part 2
Script Part 3

Output in our environment

Here is the output of the command in our environment:

Get-AllGroups2_Script_Output

(Screenshot property of ©Microsoft 2020)

I hope it helps like you, as it helps a lot of our customers. We support you for scripting and covering all topics around access rights management and specially we are the experts, because we were part of the former Protected Networks GmbH family which developed 8MAN.

Brauchen Sie Hilfe oder Unterstützung

Wünschen Sie weiterführende Informationen, so senden Sie uns gerne ein E-Mail an info@cusatum.de oder gehen über unsere Kontaktseite.

→ Wünschen Sie einen Termin: cusatum.de/termine oder +49 30 94 05 7767

Artikel teilen

Ein kurzer Überblick über die in diesem Artikel behandelten Themen.

Buchen Sie einen Termin bei unseren Experten

Buchen Sie Beratung, Demo oder Training mit den CUSATUM-Experten. Über 25 Jahre Erfahrung im Berechtigungsmanagement.

Weitere Artikel

Buchen Sie einen Termin bei unseren Experten

Buchen Sie Beratung, Demo oder Training mit den CUSATUM-Experten. Über 25 Jahre Erfahrung im Berechtigungsmanagement.

Weitere Artikel