Greetings! I’m new to powershell universal and am looking for a way to see the verbose|debug output of my powershell code running in an endpoint in the “log” view of an endpoint. From what I can tell, the log view only shows things written to the host or info output stream. How are others logging and debugging their functions?
From what I can tell there are a few ways to do this.
- In each endpoint, redirect the verbose stream to the output stream like this:
invoke-somefunction -Verbose 4>&1 | ForEach-Object {
if ( $_.GetType().Name -match 'verbose' ) {
return Write-PSULog -Message "[VERBOSE] $_"
}
return $_
}
- Create a middleware layer that runs at each request? (I’ve seen the middleware script but haven’t tried it)
- Create a custom powershell logging target that writes the output of the verbose stream to a local log file. In this scenario you can’t view the log in the admin console though.
Ideally, I’d like to avoid modifying the underlying powershell module I’m calling and instead be able to use it as it and just capture and view any debug or verbose output.
Any suggestions? Thanks!