Skip to content

Instantly share code, notes, and snippets.

@poshcodebear
Created July 30, 2015 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poshcodebear/a66bed5b18c6642385de to your computer and use it in GitHub Desktop.
Save poshcodebear/a66bed5b18c6642385de to your computer and use it in GitHub Desktop.
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
Copy link
Author

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