What are the best practices when it comes to Write-Verbose where you also have Write-Warning and Write-Error? Should I log all messages in the Verbose stream even if I already presented it to the user in a different stream?
For example, if I am starting a file copy, I might state that in verbose, but if a file already exists, I would write a warning for it. Would I put that same message into a verbose message in addition to the warning message? In other words, should I treat the verbose stream as a holistic stream of all events that occurred?
Verbose should, generally, list what's being attempted — and perhaps when the action has been successfully completed as well, if listing that is meaningful in context.
Warnings should be emitted whenever a non-critical failure or potentially dangerous action has occurred.
Depending on the situation, you may want to implement ShouldProcess to cover some of these scenarios. For example, if you need to overwrite a file that the user may not want to be overwritten, you can implement ShouldProcess in order to prompt the user when this might occur and ask them how to proceed.
The topic ‘Data Stream Best Practices’ is closed to new replies.