XML ChildNode retrieve value

Welcome Forums General PowerShell Q&A XML ChildNode retrieve value

Viewing 2 reply threads
  • Author
    Posts
    • #229816
      Participant
      Topics: 12
      Replies: 12
      Points: 60
      Rank: Member

      I’m looking through some GPO settings using Get-GPOReport¬† with the ReportType of Xml. The setting I’m looking at is on the Computer Configuration > Preferences > Windows Settings > Files.

      $ReferenceGPOId="69564100-428E-4272-B12A-886986E68F92"
      [xml]$ReferenceGPOReport=Get-GPOReport -Guid $ReferenceGPOId -ReportType Xml
      $ReferenceGPO=$ReferenceGPOReport.GPO.Computer.ExtensionData.Extension
      
      $q1=$ReferenceGPO | Where-Object {$_.q1}
      $q1.ChildNodes.ChildNodes | Select-Object -Property *

      When I see the ChildNodes property, I see these values:

      ChildNodes : {q1:GPOSettingOrder, q1:Properties, q1:Filters}

      But when I try to access the values, I only get :

      #text
      -----
      1

      I tried to look at the members and going through the properties to see if I could retrieve the information, but I couldn’t. I might be able to do it in a string, but I’m sure there’s another way to get that information. Any body know how?

    • #229825
      Participant
      Topics: 12
      Replies: 1623
      Points: 2,565
      Helping Hand
      Rank: Community Hero

      It’s difficult to assist without seeing the actual schema of the XML and what exactly you are attempting to get, but if you are selecting a node q1, why not just continue with dot notation.

      $ReferenceGPO=$ReferenceGPOReport.GPO.Computer.ExtensionData.Extension.q1
      

      Normally, you can just keep using intellisense to continue to get to the node you want to see. If you do want to post XML, you may need to do https://gist.github.com/

    • #229840
      Participant
      Topics: 12
      Replies: 12
      Points: 60
      Rank: Member

      Surprising I actually found the answer.

      $q1.ChildNodes.ChildNodes.ChildNodes.LocalName

      I actually found the answer by doing this:

      $q1.ChildNodes.ChildNOdes.ChildNodes | Select-Object -Property *
Viewing 2 reply threads
  • You must be logged in to reply to this topic.