I wish I had known this before the scripting games. Tee-Output would have helped me.
Also, one of the comments is something that we talked about at the GMSC meeting, capturing verbose output. After a bit of research, that looks like something that was built into Powershell 3.0.
Neil's comment:
One of the things I have struggled with my scripts is capturing a verbose output.A bit of research brought me to this:
For example:
copy-item c:\testing\test.pdf C:\testing2 -verbose
The verbose comes out to the screen beautifully but I can't seem to figure out how to capture it to a file. I would like to capture to a file so that I can make sure the script was doing what I was thinking it was doing.
https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=297055&SiteID=99
It seems like it would be nice these "other" information/output channels
were assigned to streams so they could participate in stream redirection
like stderr (2>&1) e.g.:
...4 - verbose (write-verbose and cmdlet -verbose output)
And it looks like Microsoft has addressed this in Powershell 3.0.
# Scenario 3
# Redirect all output to a file (*>$filename)
$(Write-Output "Pipeline Output"; Write-Warning "Warning Output"; Write-Verbose "Verbose Output"; Write-Error "Error Output"; Write-Debug "Debug Output") *>$filename
# All output is now in the file
Get-Content $filename