=Testing for old version of PowerShellGet

This commit is contained in:
lksz 2021-03-26 18:10:18 +00:00
parent aa44d120e4
commit 91199f7bcf
3 changed files with 18 additions and 1 deletions

View file

@ -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 );