# GPO Links to SOMPath multiple values

**URL:** <https://forums.powershell.org/t/gpo-links-to-sompath-multiple-values/15778>\
**Category:** PowerShell Help\
**Created:** [February 27, 2021, 6:31am UTC](https://forums.powershell.org/t/gpo-links-to-sompath-multiple-values/15778 "2021-02-27T06:31:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisagardner63](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@chrisagardner63](https://forums.powershell.org/u/chrisagardner63)\
**Post date:** [February 27, 2021, 6:31am UTC](https://forums.powershell.org/t/gpo-links-to-sompath-multiple-values/15778/1 "2021-02-27T06:31:46Z")

</div>

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…

```auto
 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
                                             'Domain'=$GPO.DomainName
                                             'ID'=$GPO.ID
                                             'OU Link Path'=$gporeport.gpo.linksto.SOMPath} 
                    
                    Write-Output $obj
                    export-csv gpoinfo.csv -InputObject $obj -Append -NoTypeInformation
                }#Foreach

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 27, 2021, 1:58pm UTC](https://forums.powershell.org/t/gpo-links-to-sompath-multiple-values/15778/2 "2021-02-27T13:58:01Z")

</div>

Chris,

welcome to [Powershell.org forums](https://forums.powershell.org).  
Next time you may assign your question to a category. This may speed up to get some answers. 😉

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

```auto
$Domain = 
    (Get-ADDomain).dnsroot
$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
    [pscustomobject]@{
        'GPOName' = $GPO.DisplayName
        'Domain' = $GPO.DomainName
        'ID' = $GPO.ID
        'OU Link Path' = ($gporeport.gpo.linksto.SOMPath) -join ','
    }
}
$Result
$Result |
    Export-Csv -Path gpoinfo.csv -NoTypeInformation -Delimiter ';' -Force

```

---

<div class="post-metadata">

**Author:** ![chrisagardner63](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@chrisagardner63](https://forums.powershell.org/u/chrisagardner63)\
**Post date:** [February 27, 2021, 4:51pm UTC](https://forums.powershell.org/t/gpo-links-to-sompath-multiple-values/15778/3 "2021-02-27T16:51:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/gpo-links-to-sompath-multiple-values/15778/4 "2024-05-16T20:27:50Z")

</div>


