PowerShell Scripts, Tips, Expert Advices, Forums, and Resources

image rotation

Welcome to PowerShell.com, the educational and community site for Windows PowerShell People. Get a quick overview.

Latest Scripts

04-06-2014 - Organize Pictures by Date
04-03-2014 - BlueCat/Proteus API functions
04-03-2014 - Function to build WSDL DLL

As a Powershell.com member you will have access to:

  • Daily PowerShell tips written by Microsoft MVPs and other leading Windows PowerShell experts
  • Free Windows PowerShell advice and training provided by Microsoft MVPs and other leading Windows PowerShell experts
  • Access to leading Windows PowerShell blogs
  • A free ebook, Mastering PowerShell, written by Microsoft MVP Dr. Tobias Weltner
PowerTip of the Day

Hiding Terminating Errors

Occasionally, you may have noticed that cmdlets throw errors although you specified "SilentlyContinue" as -ErrorAction.

The -ErrorAction parameter can only hide non-terminating errors (errors that originally were handled by the cmdlet). Any error that was not handled by the cmdlet is called "terminating". These errors are typically security-related and never covered by -ErrorAction.

So if you are a non-Administrator, the following call will raise an exception even though -ErrorAction asked to suppress errors:

To suppress terminating errors, you must use an error handler:

try
{
  Get-EventLog -LogName Security 
}
catch
{} 

Twitter This Tip! ReTweet this Tip!

Copyright 2012 PowerShell.com. All rights reserved.