GPO Links to SOMPath multiple values

Getting started at a large environment, and checking GPO information.

I have a script that gets all GPO’s (there are alot…) the grabs name, domain, ID and the SOMPath.

I have a group of GPO’s that are linked to multiple OU’s. which is returned by $gporeport.gpo.linksto.SOMPath. My CSV returns System.Object.
I am somewhat stumped by how I can list out the 2 or 3 OU paths. I cant figure out how to test for multiple values, or it may that its late…

 Foreach($sysvolGuid in $sysvolGuids)
                    $GPO = $null
                    $gporeport = $null
                    #Write-Host $sysvolGuid
                    $GPO = get-gpo -Domain $Domain -guid $sysvolGuid
                    [xml]$gporeport = get-gporeport -Domain $Domain -Guid $sysvolGuid -ReportType xml
                    $obj = [pscustomobject]@{'GPOName'=$GPO.DisplayName
                                             'OU Link Path'=$gporeport.gpo.linksto.SOMPath} 
                    Write-Output $obj
                    export-csv gpoinfo.csv -InputObject $obj -Append -NoTypeInformation


welcome to forums.
Next time you may assign your question to a category. This may speed up to get some answers. :wink:

I streamlined your code a little bit. It worked this way in my single domain environment.

$Domain = 
$DC = 
    Get-ADDomainController -DomainName $Domain -Discover

$sysvolGuids =
Get-ChildItem    \\$($DC.Name)\sysvol\$($Domain)\Policies -Filter '{*}' |
    ForEach-Object {($_.Name).toString().trim('{}')} 

$Result =
Foreach ($sysvolGuid in $sysvolGuids) {
    $GPO = 
        Get-GPO -Domain $Domain -guid $sysvolGuid
    [xml]$gporeport = 
        Get-GPOReport -Domain $Domain -Guid $sysvolGuid -ReportType xml
        'GPOName'      = $GPO.DisplayName
        'Domain'       = $GPO.DomainName
        'ID'           = $GPO.ID
        'OU Link Path' = ($gporeport.gpo.linksto.SOMPath) -join ','
$Result |
    Export-Csv -Path gpoinfo.csv -NoTypeInformation -Delimiter ';' -Force

Thank you, I was trying to use the -join, but obviously not the correct way.

And, thanks for the re-write. I need to improve my script writing and forcing myself to get started with functions. I recently purchased Don Jones PS Scripting book and working my way through. Seeing a different version of my attempt is very helpful.