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
    Posts
    • #251486
      Participant
      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 1 month ago by AlexW.
      • This topic was modified 4 weeks, 1 day ago by grokkit.
    • #255200
      Participant
      Topics: 6
      Replies: 120
      Points: 127
      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
      js
      Participant
      Topics: 32
      Replies: 842
      Points: 2,687
      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: 1309
      Points: 4,781
      Helping Hand
      Rank: Community Hero

      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.

      http://www.viapowershell.com/2016/06/hidden-formatting.html

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

      • This reply was modified 1 week, 4 days ago by kvprasoon. Reason: post correction
Viewing 3 reply threads
  • You must be logged in to reply to this topic.