Trying to export AD with PowerShell and get the values for each ADPropertyValueCollection

58 views Asked by At

So I am running a simple script to get all of our AD groups in our domain along with their CN values (Distinguished name) it is part of a project to search for group nesting. My script below returns the group name but next column displays the error "enter image description here Am I missing something here? Ultimately just want the group name and the distinguished name so I can analyze which groups have nesting.

Get-ADGroup -filter * -Properties MemberOf |
  Where-Object {$_.MemberOf -ne $null} |
  Select-Object Name,MemberOf |
    Export-Csv C:\Users\XXXXX\Documents\NestedGroups_2.csv
1

There are 1 answers

3
Nixphoe On

I believe you can pull out the MemberOf by doing this.

Get-ADGroup -filter * -Properties MemberOf |
  Where-Object {$_.MemberOf -ne $null} |
  Select-Object Name,@{Name="MemberOf";Expression={$_.MemberOf -join ":"}}