Suppressing VERBOSE for Import-Module
I could not get the solutions above to work with all modules (I'm using Powershell 4.0). This is the solution I ended up using and so far it has worked with every module I've used:
At the top of my script file I have this, to make the -Verbose work for the script (the script has no parameters):
[CmdletBinding()]
Param()
Then when I'm ready to import the modules, I do this:
$SaveVerbosePreference = $global:VerbosePreference;
$global:VerbosePreference = 'SilentlyContinue';
Import-module "Whatever";
$global:VerbosePreference = $SaveVerbosePreference;
Then I just call the script like so:
PowerShell -file something.ps1 -Verbose
Import-Module Carbon -Verbose:$false | Out-Null
I think a better solution than the one which is marked here is to redirect the verbose output to a different stream. This way you can print the output if you need it and it doesn't get swollen for ever:
Import-Module Carbon 4>&5
This redirects the verbose stream (4) to the debug stream (5). When you run your script with the Verbose switch, it will not output the verbose lines from Import-Module, but you can bring it back by running your script with the -Debug switch.
Try Import-Module Carbon -Verbose:$false