Skip to content

Commit 0c2d369

Browse files
serkanzSerkan ZENGİNTylerLeonhardt
authored
TLS 1.2 Support When Installing PackageManagement Module (#1315)
* the powershell command to install the update should include the command to use TLS1.2 * Update src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs Co-authored-by: Tyler James Leonhardt <tylerl0706@gmail.com> * Enhanced package update failure message on line 143 and added Repository option to Install-Module command * Revert "Enhanced package update failure message on line 143 and added Repository option to Install-Module command" This reverts commit 7975481. * Enhanced error message while installing PackageManagement * Repository argument put outside of single quote by mistake. Co-authored-by: Serkan ZENGİN <szengin@ssb.gov.tr> Co-authored-by: Tyler James Leonhardt <tylerl0706@gmail.com>
1 parent 5958ac5 commit 0c2d369

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private async Task CheckPackageManagement()
8282
foreach (PSModuleInfo module in await _powerShellContextService.ExecuteCommandAsync<PSModuleInfo>(getModule))
8383
{
8484
// The user has a good enough version of PackageManagement
85-
if(module.Version >= s_desiredPackageManagementVersion)
85+
if (module.Version >= s_desiredPackageManagementVersion)
8686
{
8787
break;
8888
}
@@ -100,7 +100,7 @@ private async Task CheckPackageManagement()
100100
{
101101
Message = "You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?",
102102
Type = MessageType.Warning,
103-
Actions = new []
103+
Actions = new[]
104104
{
105105
new MessageActionItem
106106
{
@@ -118,7 +118,7 @@ private async Task CheckPackageManagement()
118118
{
119119
StringBuilder errors = new StringBuilder();
120120
await _powerShellContextService.ExecuteScriptStringAsync(
121-
"powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'",
121+
"powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Repository PSGallery'",
122122
errors,
123123
writeInputToHost: true,
124124
writeOutputToHost: true,
@@ -140,7 +140,7 @@ await _powerShellContextService.ExecuteScriptStringAsync(
140140
_languageServer.Window.ShowMessage(new ShowMessageParams
141141
{
142142
Type = MessageType.Error,
143-
Message = "PackageManagement update failed. Please run the following command in a new Windows PowerShell session and then restart the PowerShell extension: `Install-Module PackageManagement -Force -AllowClobber -MinimumVersion 1.4.6`"
143+
Message = "PackageManagement update failed. This might be due to PowerShell Gallery using TLS 1.2. More info can be found at https://aka.ms/psgallerytls"
144144
});
145145
}
146146
}

0 commit comments

Comments
 (0)