Verbose Message ANSI Alternatives
If you've been following my work for a while, you know I am a big fan of using Write-Verbose
. I find the verbose output very helpful when I am writing a PowerShell function. The verbose output writes to a separate stream and is identifiable in the console.
VERBOSE: [14:17:41.9281665 BEGIN ] Running under PowerShell version 7.4.3
Lately, I've been experimenting with alternatives. Instead of verbose output that is intermingled with the output and that scrolls with the output, I'd like to have a message that is displayed in a specific area, with each message overwriting the previous one. I don't always care about the verbose output after the command finishes. Maybe I only need to see the messages while the code is executing.
One way I can accomplish this is by leveraging ANSI escape sequences. You are probably familiar with them from $PSStyle
to add foreground and background color or styles. But there are also escape sequences that allow you to move the cursor around the console window. You can find this documented on Wikipedia.