PowerShell logging
PowerShell has a number of ways to record what we do with it. In this section, we’re going to look at three of them – over the shoulder logging, deep script block logging, and module logging.
Over the shoulder logging
PowerShell can record a transcript of a session, using the Start-Transcript
and Stop-Transcript
cmdlets. The transcript function will record everything that is displayed on the screen. This is useful for recording what we do and the output we get, and then sharing it with others.
We can set the path where the transcript is saved using the -Path
parameter, and we add to an existing transcript with the -Append
parameter, followed by the name and path of an existing transcript. The -InvocationHeader
parameter logs the time each command was run. When we want to stop recording, we can use the Stop-Transcript
cmdlet.
In older versions of PowerShell, we had to perform some magic to ensure that transcription was turned on, and even...