The issue you are experiencing with the logging output on the Windows 11 VM used as a Hybrid worker may be related to the differences in how PowerShell 7.x handles output compared to PowerShell 5.1. In PowerShell 7.x, the output may include ANSI escape sequences for formatting, which can appear as gibberish if the output is not rendered correctly in the environment you're using.
To resolve this issue and achieve the expected logging output, you can try the following configuration changes on the Windows 11 VM:
- Disable ANSI Escape Sequences: You can configure your PowerShell session to disable ANSI escape sequences. This can be done by setting the
$OutputPreferencevariable at the beginning of your runbook:
This setting will suppress the output that includes formatting codes.$OutputPreference = "SilentlyContinue" - Explicitly Set Logging Preferences: Ensure that you explicitly set the logging preferences at the start of your runbook as follows:
This will help ensure that the logging behaves as expected.$VerbosePreference = "Continue" $ProgressPreference = "Continue" - Check PowerShell Version Compatibility: Ensure that all modules you are using are compatible with PowerShell 7.x, as some modules may behave differently or have known issues when run in this environment.
- Review Runbook Code: If your runbook is dependent on specific internal paths or uses features not supported in PowerShell 7.x, consider revising the code to avoid these dependencies.
By implementing these changes, you should be able to achieve logging output similar to what you see in the Azure "Sandbox" worker.