October 15th, 2012

PowerTip: Suppress PowerShell Module Import Warning Messages

Doctor Scripto
Scripter

Summary: Learn how to use the warning redirection operator to suppress Windows PowerShell warning messages when importing a module.

Hey, Scripting Guy! Question How can you hide the warning message from a Windows PowerShell module when you import it if the module contains an unapproved verb?

Hey, Scripting Guy! Answer Use the warning stream redirection operator when importing the module, and redirect the warning message to $null:

Import-Module *sql* 3>$null

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.