Skip to content

Instantly share code, notes, and snippets.

@jimmehc
jimmehc / gist:8d450a3792ce5b5141ef
Last active August 29, 2015 14:24
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}}}