-
Notifications
You must be signed in to change notification settings - Fork 0
Proxy Functions
The following proxy functions will log anything sent to those proxy functions while keeping the original funtionality of those functions in tact.
Keep in mind, that some messaging will only be logged if it would have been outputted to the screen.
This is configured with the Preference Variables.
So, if you want to see verbose messages, be sure to set $VerbosePreference
to Continue
.
ℹ: Understanding the proxy function tables in the following sections ... The condition is a valid statement that can just be pasted into a PowerShell CLI to determine if the current state is
$true
or not. If it is true, the other columns tell you how that statement affects that function, if at all. The proxy function can only perform the action in the header of the column if:
- At lease one condition is
$true
that would grant (✅) the action.- No condition is
$true
that would deny (❌) the action.
The Write-Debug
cmdlet writes debug messages to the host from a script or command.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Writes to Console | Writes to Log |
---|---|---|
$DebugPreference -ne 'SilentlyContinue' |
✅ * | ✅ |
$DebugPreference -eq 'SilentlyContinue' |
❌ * | ❌ |
$env:PSWriteLogDebugSilent -as [bool] |
❌ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |
The Write-Error
cmdlet declares a non-terminating error.
By default, errors are sent in the error stream to the host program to be displayed, along with output.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Writes to Console | Writes to Log |
---|---|---|
$true # Default
|
✅ | ✅ |
$env:PSWriteLogErrorSilent -as [bool] |
❌ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |
The Write-Host
cmdlet's primary purpose is to produce for-(host)-display-only output, such as printing colored text like when prompting the user for input.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Writes to Console | Writes to Log |
---|---|---|
$true # Default
|
✅ | ✅ |
$env:PSWriteLogHostSilent -as [bool] |
❌ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |
The Write-Information
cmdlet specifies how PowerShell handles information stream data for a command.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Writes to Console | Writes to Log |
---|---|---|
$InformationPreference -ne 'SilentlyContinue' |
✅ * | ✅ |
$InformationPreference -eq 'SilentlyContinue' |
❌ * | ❌ |
$env:PSWriteLogInformationSilent -as [bool] |
❌ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |
The Write-Output
cmdlet writes the specified objects to the pipeline.
If Write-Output
is the last command in the pipeline, the objects are displayed in the console.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Writes to Console | Writes to Log |
---|---|---|
$true # Default
|
✅ | |
$env:PSWriteLogOutputLog -as [bool] |
✅ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |
ℹ: Unlike the other
Write-*
cmdlets that don't have a preference variable,Write-Output
has to be explicitely enabled for logging.
The Write-Progress
cmdlet displays a progress bar within a PowerShell command window.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Displays on CLI | Writes to Log |
---|---|---|
$ProgressPreference -ne 'SilentlyContinue' |
✅ * | ✅ |
$ProgressPreference -eq 'SilentlyContinue' |
❌ * | ❌ |
$env:PSWriteLogProgressSilent -as [bool] |
❌ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |
ℹ: Since this isn't standard text output, the way I've chosen to log this information is based on what was useful to me.
The Write-Verbose
cmdlet writes text to the verbose message stream.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Writes to Console | Writes to Log |
---|---|---|
$VerbosePreference -ne 'SilentlyContinue' |
✅ * | ✅ |
$VerbosePreference -eq 'SilentlyContinue' |
❌ * | ❌ |
$env:PSWriteLogVerboseSilent -as [bool] |
❌ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |
The Write-Warning
cmdlet writes a warning message.
We've proxied this function and added a call to Write-Log
, if the conditions are right ...
Condition | Writes to Console | Writes to Log |
---|---|---|
$WarningPreference -ne 'SilentlyContinue' |
✅ * | ✅ |
$WarningPreference -eq 'SilentlyContinue' |
❌ * | ❌ |
$env:PSWriteLogWarningSilent -as [bool] |
❌ | |
$env:PSWriteLogDisableLogging -as [bool] |
❌ ** |