I'm creating a .ps1 script which invokes Write-Verbose. I would like to be able to enable/disable these.
I was hoping that I could pass the -Verbose flag when invoking the script and everything would just work. Unfortunately this doesn't seem to be the case.
The verbose messages are not written out to the host. I looked around a bit and found Supporting -Whatif, -Confirm, -Verbose – In SCRIPTS!
But this is from 2007 and the PS team member stated that they were looking for built in support in PS v2.
Anybody have any updates on this or do we have to use the same technique described in that blog post?
Here is an example of the current behavior.
I created a simple script,ex01.ps1, with the following.
Write-Host "line 1"
Write-Verbose "line 2"
Write-Host "line 3"
I first executed the script with .\ex01.ps1, and only 1 & 2 were printed as expected. Then I executed it with .\ex01.ps1 -verbose, and got the same result. I was expecting all 3 lines to be printed the second time.
