Skip to content

Instantly share code, notes, and snippets.

@jimmehc
Last active August 29, 2015 14:24
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 jimmehc/8d450a3792ce5b5141ef to your computer and use it in GitHub Desktop.
Save jimmehc/8d450a3792ce5b5141ef to your computer and use it in GitHub Desktop.
PowerShell Scripting Games July 2015
# Type the remote computer name after the scriptblock to target something other than localhost
# ft purely because "ft" is 4 characters shorter than "select"
&{param($x="localhost") gwmi Win32_operatingsystem -cn $x | Add-Member @{BiosSerial=(gwmi Win32_BIOS -cn $x).SerialNumber} -pa|ft psc*,s*aj*,v*,bi*}
# This is a little shorter than that, but everyone else has done it this way
&{param($x="localhost") gwmi Win32_operatingsystem -cn $x | ft psc*,s*aj*,v*,@{n="BiosSerial";e={(gwmi Win32_BIOS -cn $x).SerialNumber}}}
# To support passing an array of multiple computer names
&{param($x="localhost") gwmi Win32_operatingsystem -cn $x | ft psc*,s*aj*,v*,@{n="BiosSerial";e={(gwmi Win32_BIOS -cn $_.PSComputerName).SerialNumber}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment