-
Notifications
You must be signed in to change notification settings - Fork 1
Logging
Raymond Piller edited this page Jan 15, 2023
·
1 revision
There are a many ways to log with PowerShell. I have created a way that works well for me whether I'm in development, or troubleshooting a production run of a PowerShell script. However, I did not build it into PSRedstone. I believe that it can, and should, stand alone as its own module and be used regardless of if you are using PSRedstone or not. So, check out PSWriteLog and decide for yourself. If you don't love it, come up with your own way of logging that suits your needs.
Here's how I set up PSWriteLog in my Redstone Block:
#region Redstone Block
#Requires -Modules @{ModuleName = 'PSRedstone'; RequiredVersion = '2023.1.4.62137'},@{ModuleName = 'PSWriteLog'}
$redstone, $settings = New-Redstone
$env:PSWriteLogFilePath = $redstone.Settings.Log.File.FullName
$env:PSWriteLogIncludeInvocationHeader = $true
$InformationPreference = 'Continue'
#endregion Redstone Block
ℹ: If any of that is confusing to you, I suggest that you head over to the PSWriteLog README for details.