PowerTip: Suppress PowerShell Module Import Warning Messages

PowerTip: Suppress PowerShell Module Import Warning Messages

  • Comments 3
  • Likes

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • You can also run:

    Import-Module -DisableNameChecking MODULENAME

  • @Bob Schumaker you are absolutely correct. Using the DisableNameChecking switch is easier :-) Part of my purpose in the tip was also to show an easy way to show using the redirect warning stream

  • I think the point is redirection operator, am i right? scripting guys.