From 7d2e01811458c7427011528810ac80880410950f Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:42:12 +0100 Subject: [PATCH] Fix: Use UTF8 encoding for PowerShell console (#1925) * Fix: Use UTF8 encoding for PowerShell console * Docs: Add #1925 --- Source/NETworkManager.Models/AWS/AWSSessionManager.cs | 6 +++++- docs/Changelog/next-release.md | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager.Models/AWS/AWSSessionManager.cs b/Source/NETworkManager.Models/AWS/AWSSessionManager.cs index 5e8c006e15..a957c84c63 100644 --- a/Source/NETworkManager.Models/AWS/AWSSessionManager.cs +++ b/Source/NETworkManager.Models/AWS/AWSSessionManager.cs @@ -2,9 +2,13 @@ { public static partial class AWSSessionManager { + private static string _encodingCommand = "[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding"; + private static string _setLocationCommand = "Set-Location -Path ~"; + private static string _clearHostCommand = "Clear-Host"; + public static string BuildCommandLine(AWSSessionManagerSessionInfo sessionInfo) { - var commandLine = $"-NoExit -NoLogo -NoProfile -Command \"Set-Location -Path ~; Clear-Host; aws ssm start-session --target {sessionInfo.InstanceID}"; + var commandLine = $"-NoExit -NoLogo -NoProfile -Command \"{_encodingCommand}; {_setLocationCommand}; {_clearHostCommand}; aws ssm start-session --target {sessionInfo.InstanceID}"; // Add profile if (!string.IsNullOrEmpty(sessionInfo.Profile)) diff --git a/docs/Changelog/next-release.md b/docs/Changelog/next-release.md index 38e0b8eb8e..eb1a799190 100644 --- a/docs/Changelog/next-release.md +++ b/docs/Changelog/next-release.md @@ -34,7 +34,8 @@ New Feature - [IP Scanner](https://borntoberoot.net/NETworkManager/Documentation/Application/IPScanner){:target="\_blank"} ## Bugfixes - +AWS Session Manager + - Use UTF-8 encoding for embedded PowerShell console window [#1832](https://github.com/BornToBeRoot/NETworkManager/pull/1832){:target="\_blank"} ## Other - Language files updated [#transifex](https://github.com/BornToBeRoot/NETworkManager/pulls?q=author%3Aapp%2Ftransifex-integration){:target="\_blank"}