Weird behavior when using psversiontable with ‘Get-GPO’

Welcome Forums General PowerShell Q&A Weird behavior when using psversiontable with ‘Get-GPO’

Viewing 3 reply threads
  • Author
    • #251486
      Topics: 1
      Replies: 12
      Points: 124
      Team Member
      Rank: Participant

      I stumbled upon this weird behavior, I wanted to show the powershell version and then grab GPO info.
      When I append $psversiontable, I get a super funky output
      I tested this on a Windows Server 2019 , 1809 box.

      When I run it with the $psversiontable, it is not showing the User or computerversion.

      Does anyone have the same weird behavior or has seen this before?

      • This topic was modified 3 months ago by AlexW.
      • This topic was modified 3 months ago by grokkit.
    • #255200
      Topics: 6
      Replies: 120
      Points: 128
      Helping Hand
      Rank: Participant

      The 3 most important cmdlets in PowerShell are Get-Command, Get-Help and Get-Member Try piping the output to Get-Member at the end of either line and see what is returned.

    • #255275
      Topics: 32
      Replies: 850
      Points: 2,749
      Helping Hand
      Rank: Community Hero

      Funny things happen when combining the output of multiple commands. Format-table runs in the background and doesn’t handle it exactly the way you’d expect. I think pipe the second one to format-list * to see all the properties.

    • #255359
      Senior Moderator
      Topics: 9
      Replies: 1408
      Points: 5,227
      Helping Hand
      Rank: Community MVP

      This behavior is because of the formatting subsystem. When multiple expression comes in a single pipeline, then the formatting for the first one will be applied and the remaining will not get the proper formatting. You can pipe the second expression to Out-Default.

      I think user config and computer config values are calculated during formatting. You can check it in the GPO modules folder which will probably have a formatting file in xml format. I had an old blog post regarding formatting. You can have a look at it.

      PS: this behavior is changed in PowerShell core for built-in cmdlets.

      • This reply was modified 2 months, 2 weeks ago by kvprasoon. Reason: post correction
Viewing 3 reply threads
  • You must be logged in to reply to this topic.