This time we are going to see a small script which allows you to obtain a report of all the users of your domain controller and the group that those users belong to:
Get-ADUser -Filter * -Properties DisplayName, memberof | % {
New-Object PSObject -Property @{
UserName = $_.DisplayName
Groups = ($_.memberof | Get-ADGroup | Select -ExpandProperty Name) -join «,»
}
} | Select UserName,Groups | Export-Csv C:\report.csv -NTI
Comments