Getting membership of a user, computer, and group

The function used in this section will help in finding out the group membership of users, computers, or groups. The output of this function is the same as what you will see in the MemberOf tab in the object properties. This function takes two types of input. The first one is the Name parameter and it takes a list of objects for which you want to query the membership details. The second one is the Type parameter, which indicates the class of the objects that you supplied to the Name parameter:

Function Get-ADobjectMembership { [CmdletBinding()] param( [Parameter(Mandatory=$true,Position=0)] [string[]]$Name, [Parameter(Mandatory=$true,Position=1)] [ValidateSet("User","Group","Computer")] [string]$Type ...

Get Active Directory with PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.