To list all the users from a domain with whatever groups they are member of, Use the below script (Remember it needs Quest PowerShell for Active Directory installed on the server where it is being run from) :
get-qaduser * | foreach-object {
$User = $_
(get-QADuser $user).memberof | Get-Qadgroup | select @{n="UserSAMID";e={$User}},Name,SAMAccountname,DisplayName,Type,canonicalname
} | export-csv Users_Memberof.csv -notypeinformation
This will generate a CSV file which will have user's Samid in the first column and Group name (direct membership) in the second column with other group attributes in subsequent columns.
get-qaduser * | foreach-object {
$User = $_
(get-QADuser $user).allmemberof | Get-Qadgroup | select @{n="UserSAMID";e={$User}},Name,SAMAccountname,DisplayName,Type,canonicalname
} | export-csv Users_Memberof.csv -notypeinformation
This will generate a CSV file which will have user's Samid in the first column and Group name (indirect nested group membership) in the second column with other group attributes in subsequent columns.
get-qaduser * | foreach-object {
$User = $_
(get-QADuser $user).memberof | Get-Qadgroup | select @{n="UserSAMID";e={$User}},Name,SAMAccountname,DisplayName,Type,canonicalname
} | export-csv Users_Memberof.csv -notypeinformation
This will generate a CSV file which will have user's Samid in the first column and Group name (direct membership) in the second column with other group attributes in subsequent columns.
get-qaduser * | foreach-object {
$User = $_
(get-QADuser $user).allmemberof | Get-Qadgroup | select @{n="UserSAMID";e={$User}},Name,SAMAccountname,DisplayName,Type,canonicalname
} | export-csv Users_Memberof.csv -notypeinformation
This will generate a CSV file which will have user's Samid in the first column and Group name (indirect nested group membership) in the second column with other group attributes in subsequent columns.
Here is the onliner code
ReplyDeleteget-qaduser * | foreach-object { $User = $_; (get-QADuser $user).memberof | Get-Qadgroup | select @{n="UserSAMID";e={$User}},Name,SAMAccountname,DisplayName,Type,canonicalname} | export-csv -notypeinformation c:\temp\Users_Memberof.csv
get-qaduser * -sizelimit 0 | foreach-object { $User = $_; (get-QADuser $user).memberof | Get-Qadgroup | select @{n="UserSAMID";e={$User}},Name,SAMAccountname,DisplayName,Type,canonicalname} | export-csv -notypeinformation c:\temp\Users_Memberof.csv
ReplyDelete