janikvonrotz
1/2/2014 - 1:07 PM

PowerShell: Get AD User Objects and User Objects from Group Members #PowerShell #ActiveDirectory

PowerShell: Get AD User Objects and User Objects from Group Members #PowerShell #ActiveDirectory

"ADGroup", "User1" | %{

    Get-ADObject -Filter {Name -eq $_} | %{
        
        if($_.ObjectClass -eq "user"){
            
            Get-ADUser $_.DistinguishedName
            
        }elseif($_.ObjectClass -eq "group"){
        
            Get-ADGroupMember $_.DistinguishedName -Recursive | Get-ADUser 
        }
    }
}