Very Verbose PowerShell Output

Have you ever been writing a PowerShell script and wanted verbose output to show up no matter what?

You may have thought of doing something like this:


#Save the preference variable so you can put it back later

$saveVerbosePreference=$VerbosePreference
#Override the preference variable to make the output show up

$VerbosePreference='Continue'

Write-Verbose 'This is an important message you need to see'
#Leave it like you found it

$VerbosePreference=$saveVerbosePreference

If you do that, you'll get the verbose message every time, just like you wanted.

Fortunately for you, there's a much easier way to get the message:


#By adding the -Verbose switch, you override the preference for this cmdlet

Write-Verbose 'This is an important message you need to see' -Verbose

Wasn't that easy?