PowerTip: Suppress PowerShell Module Import Warning Messages

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

Comments (3)

  1. Anonymous says:

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

  2. Bob Schumaker says:

    You can also run:

    Import-Module -DisableNameChecking MODULENAME

  3. Ed Wilson says:

    @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

Skip to main content