A. Much like the -EA parameter, all cmdlets have a common parameter called -ErrorVariable (or -EV). Specify the name of a variable (which does not include the $ in front of the name), and any errors will be put into that variable. Here's an example:
Try {
Gwmi Win32_BIOS -comp localhost,not-online -EA Stop -EV Err
} catch {
Write-Host "Uh, oh $Err happened" -fore red -back white
}
To read about other common parameters, run
help about_common_parameters
in the shell.
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.