From 91199f7bcf48d52df6763231c3fbbe5a170aa78e Mon Sep 17 00:00:00 2001 From: lksz Date: Fri, 26 Mar 2021 18:10:18 +0000 Subject: [PATCH] =Testing for old version of PowerShellGet --- base/Get-MyModules.ps1 | 15 +++++++++++++++ base/profile.d/Style.ps1 | 3 ++- base/src/modules.json | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/base/Get-MyModules.ps1 b/base/Get-MyModules.ps1 index 9bb0096..3e7c7da 100644 --- a/base/Get-MyModules.ps1 +++ b/base/Get-MyModules.ps1 @@ -2,6 +2,21 @@ param([switch]$IgnoreSystem,[switch]$MissingOnly) $local:currentSys = @('Always') + ([SystemName]::_GetValidValues('',$true,$true)); +$local:oldPSGet = Get-Module PowerShellGet -ListAvailable -ErrorAction SilentlyContinue | + Sort-Object -Property Version -Descending | + Select-Object -First 1 | + Where-Object { $_.Version.Major -eq 1 } +if( $local:oldPSGet ) { + Write-Warning $(@( + "PowerShellGet is an old version ($($oldPSGet.Version)), the following code should upgrade it" + , " [Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" + , " Install-PackageProvider -Name NuGet -Force" + , " Remove-Module PowerShellGet" + , " Install-Module -Name PowerShellGet -Force" + , " Update-Module -Name PowerShellGet" + ) -join "`n" ) +} + [MyConfig]::GetConfigPaths('mymodules',$false) | ForEach-Object { $local:modules = $( Get-Content $_ | ConvertFrom-Json ); diff --git a/base/profile.d/Style.ps1 b/base/profile.d/Style.ps1 index f635f5a..75acb43 100644 --- a/base/profile.d/Style.ps1 +++ b/base/profile.d/Style.ps1 @@ -1,4 +1,5 @@ -Get-Command Set-PSReadLineKeyHandler | ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete } +Get-Command Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue | + ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete } if( Get-Command Set-PoshPrompt -ErrorAction SilentlyContinue ) { $local:poshPrompt = Join-Path $HOME ".oh-my-posh.omp.json" if( -not (Test-Path $poshPrompt) ) { $poshPrompt = "slim" } diff --git a/base/src/modules.json b/base/src/modules.json index f4bba93..c3241c8 100644 --- a/base/src/modules.json +++ b/base/src/modules.json @@ -1,5 +1,6 @@ { "Always": [ + "psreadline", "PowerShellCookbook", "oh-my-posh", "posh-git",