A. Let's say you want your script to retrieve and display two pieces of information—the BIOS serial number and Windows version—it in a table. The key is to output that information on a custom object:
$os = gwmi win32_operatingsystem<br>$bios = gwmi win32_bios<br>$obj = new-object psobject<br>$obj | add-member noteproperty OSBuild ($os.buildnumber)<br>$obj | add-member noteproperty BIOSSerial ($bios.serialnumber)<br>write-output $obj<br><br>
Doing so opens up a bunch of output possibilities. Let's say all that was contained in a file named C:\Get-Info.ps1:
C:\Get-Info | Out-GridView<br>C:\Get-Info | Export-CSV Info.csv<br>C:\Get-Info | Format-Table -autosize<br><br>
You can do anything with script output if it's in the form of objects.
Do you have a Windows PowerShell question? Why not submit it to Don? Post your question at www.windowsitpro.com/FAQs/FAQSubmittalForm.aspx and you might see your answer online! Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.