Exporting Tree AD Groups with members to csv
Exporting Tree AD Groups with members to csv
Print on the screen:
$group = @{ filter = "GroupCategory -eq 'security'" SearchBase = "OU=Security Groups,DC=Domainname,DC=local" properties = "members" } get-adgroup @group | select @{n='GroupName';e={$_.samaccountname}}, @{n='Name';e={($_.members | get-adobject).name -join "`n"}}
Print to csv file - export.csv:
$group = @{ filter = "GroupCategory -eq 'security'" SearchBase = "OU=Group Name,DC=Domain,DC=Domain" properties = "members" } get-adgroup @group | select @{n='GroupName';e={$_.samaccountname}}, @{n='Name';e={($_.members | get-adobject).name -join "`n"}} | export-csv "export.csv" -notypeinformation -Force
With UTF-8:
$group = @{ filter = "GroupCategory -eq 'security'" SearchBase = "OU=Security Groups,DC=Domainname,DC=local" properties = "members" } get-adgroup @group | select @{n='GroupName';e={$_.samaccountname}}, @{n='Name';e={($_.members | get-adobject).name -join "`n"}} | export-csv "groupexport.csv" -notypeinformation -Force -Encoding UTF8
Dodaj komentarz