November 15, 2011

How to use Write-Verbose in a script ?

This one is quite easy, simply add a write-verbose command in your script :

write-verbose "The script is running !"

Then launch your script with the –verbose parameter :

.\myscript.ps1 -verbose
Explanation :

By default write-verbose output is not display because the default value of $VerbosePreference is set to SlientlyContinue. By adding the –verbose parameter, the value of $VerbosePreference is set to Continue (in the context of the script). 

No comments:

Post a Comment