Skip to content

$cs.Job_EnableLog

Re-enables logging that was previously turned off with $cs.Job_DisableLog.

$cs.Job_EnableLog(string text = null)

Optional text to write to the log once, after logging is switched back on. If omitted, nothing is logged.

None

Re-enable logging after a single suppressed check:

Terminal window
$cs.Job_DisableLog("Temporarily disabling logging while checking for optional component")
$installed = $cs.MSI_IsMSIGuidInstalled('{AC76BA86-1033-FF00-7760-BC15014EA700}')
$cs.Job_EnableLog("Re-enabling logging")

Re-enable logging after wrapping a single noisy native command, and log a short summary of the result once logging is back on:

Terminal window
$cs.Job_DisableLog("Silencing log while running vendor CLI health check")
$result = & "$global:Packageroot\tools\healthcheck.exe" --quiet
$exitCode = $LASTEXITCODE
$cs.Job_EnableLog("Health check finished with exit code $exitCode")

Wrap the suppressed section in try/finally so logging is guaranteed to be re-enabled even if the check throws an unexpected error:

Terminal window
try {
$cs.Job_DisableLog("Silencing log while checking for a flaky optional dependency")
$installed = $cs.MSI_IsMSIGuidInstalled('{AC76BA86-1033-FF00-7760-BC15014EA700}')
} finally {
$cs.Job_EnableLog("Re-enabling logging")
}

$cs.Job_DisableLog