Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scripting Games July 2015 entry
param($Comp = 'localhost') (gwmi Win32_OperatingSystem -Comp $Comp | select PSComputerName, ServicePackMajorVersion, Version, @{l='BIOSSerial';e={gwmi Win32_BIOS -Comp $Comp | select -expand SerialNumber}} | Out-String).Replace("`n","`t`t`t").TrimStart()
@poshcodebear

This comment has been minimized.

Copy link
Owner Author

poshcodebear commented Jul 30, 2015

Some things I want to make note of here:

  • the sample output that we were given to imitate was also a single line, meaning that the output they're looking for is flattened. I've done my best to imitate that by converting the output to a string, then replacing the literal linebreaks with three tab characters, which appears to be close to what they had; I also trimmed the start so that it wouldn't have extra space at the beginning, which wasn't shown in the sample output.
  • If the intention was NOT to imitate the flattened string output (though I suspect it was), you can get that by removing everything from the last pipe character on, and the opening parentheses after the Param block.
  • I used Param here, which means it will work fine if you just paste it on the command line and change the value of $Comp, or if you save it as a ps1 file and use -Comp to pass it the computer names you want to use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.