Public/Get-GroupMembership.ps1
Function Get-GroupMembership { [CmdletBinding()] param ( [Parameter( ValueFromPipelineByPropertyName, Mandatory )] [Alias("SamAccountName", "DistinguishedName", "SID", "mail")] $Identity ) begin {} process { foreach ($SearchValue in $Identity) { Get-ADGroup -Filter "SamAccountName -eq '$SearchValue' -or DistinguishedName -eq '$SearchValue' -or SID -eq '$SearchValue' -or mail -eq '$SearchValue'" -Properties Members | Select-Object Members -ExpandProperty Members } } end {} } |