Q. How can I suppress an error message in PowerShell?
A. To look at other examples on the Internet, you'd think putting this at the top of your script would be the answer:
Don't do that. Sure, it'll suppress errors in your script—ALL of the errors, even helpful ones about syntax errors and so on. Instead, if you anticipate a cmdlet causing an error such as "file not found" or "could not connect" and you don't want to see the error or deal with it, use the -ErrorAction (or -EA) parameter of that cmdlet:
All cmdlets have an -EA parameter. It's part of the
Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.