# Parsing through XML help

**URL:** <https://forums.powershell.org/t/parsing-through-xml-help/13318>\
**Category:** PowerShell Help\
**Created:** [October 20, 2019, 10:46am UTC](https://forums.powershell.org/t/parsing-through-xml-help/13318 "2019-10-20T10:46:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chexmix](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@chexmix](https://forums.powershell.org/u/chexmix)\
**Post date:** [October 20, 2019, 10:46am UTC](https://forums.powershell.org/t/parsing-through-xml-help/13318/1 "2019-10-20T10:46:15Z")

</div>

I’m trying to create a report of all linked group policy objects.

I found this command which works for a single GPO

[XML]$GroupPolicy = Get-GPOReport -Name GPOName -ReportType XML  
$GroupPolicy.GPO.LinksTo.SOMPath

If I change the command to Get-GPOReport -All it lists nothing.

This command Get-GPOReport -All Type XML does put all the info I need into an XML I’m just not sure how to parse it and pull out what I need.

---

<div class="post-metadata">

**Author:** ![an0nemus](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@an0nemus](https://forums.powershell.org/u/an0nemus)\
**Post date:** [October 21, 2019, 9:06am UTC](https://forums.powershell.org/t/parsing-through-xml-help/13318/2 "2019-10-21T09:06:37Z")

</div>

What do you see if you type in

$grouppolicy

Something like:

xml GPOS

* * *

version=“1.0” encoding=“utf-16” GPOS

&nbsp;

What if you then type in

$grouppolicy.gpos

something like:

GPO

and if you type in

$grouppolicy.gpos.gpo

&nbsp;

You could also try:

$grouppolicy|get-member

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![aaron-hardy](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@aaron-hardy](https://forums.powershell.org/u/aaron-hardy)\
**Post date:** [October 24, 2019, 10:26am UTC](https://forums.powershell.org/t/parsing-through-xml-help/13318/3 "2019-10-24T10:26:46Z")

</div>

> This command Get-GPOReport -All Type XML does put all the info I need into an XML I'm just not sure how to parse it and pull out what I need.

So, what info do you need from the XML?

Regardless of what you need, you can loop through all GPOs then get the report for each one using `Get-GPOReport -Name abc`, instead of using `Get-GPOReport -All`. From your example code, here’s how it would work:

```
$allGPOs = Get-GPO -All

foreach ($gpo in $allGPOs) {

    [xml]$gpoReport = Get-GPOReport -Name $gpo.DisplayName -ReportType Xml

    # Output the SOMPath object
    $gpoReport.GPO.LinksTo.SOMPath
}
```

---

<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:31pm UTC](https://forums.powershell.org/t/parsing-through-xml-help/13318/4 "2024-05-16T20:31:12Z")

</div>


