get the security settings from GPO using xml report

Sam White 26 Reputation points
2020-09-03T05:28:42.63+00:00

I want to export the security settings of a group policy. I have exported the gpo to xml format and then I am using the below: $x.GPO.Computer.ExtenstionData.Extension

Where $x contains the xml report. However I getting the result like below:

q1 type

http://www.microsoft.com/Grouppolicy/Settings/Files q1:FileSettings

                                                                                                            q2:SecuritySettings

                                                                                                            q3:RegistrySettings

How can I extract the data inside these q1:FileSettings, q2:SecuritySettings, q3:RegistrySettings?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,546 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Ian Xue 37,541 Reputation points Microsoft Vendor
    2020-09-03T23:36:44.39+00:00

    Hi,
    It depends on how the gpo is stored in the xml file. According to the result you posted, there could be three nodes in $x.GPO.Computer.ExtenstionData.Extension and you can get them separately with $x.GPO.Computer.ExtenstionData.Extension[0], $x.GPO.Computer.ExtenstionData.Extension[1] and $x.GPO.Computer.ExtenstionData.Extension[2]. You'd better post the xml file. Otherwise no one knows how to get the data inside these nodes.

    Best Regards,

    Ian

    Please remember to "Accept Answer" and upvote if the reply is helpful.

    0 comments No comments

  2. Sam White 26 Reputation points
    2020-09-05T08:16:43.55+00:00

    Thanks for the reply. However what if there are multiple GPOs with different settings and we don't know the value we want to search is in [0], [1], [2] etc..

    If the xml has a namespace, how can I extract value from that using xpath or Select-xml.

    0 comments No comments

  3. Sam White 26 Reputation points
    2020-09-06T02:49:05.817+00:00

    Example, xml file attached:22862-testgpo1.xml

    Basically I want to know how to extract information in the namespace using Select-xml or xpath.
    So in this example xml file, I want to extract all the settings defined using powershell.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.