Use Get-Module instead of Get-InstalledModule

This commit is contained in:
Shivam Mathur 2022-01-27 07:05:46 +05:30
parent dcf2f7f74f
commit c1efd614e8
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -238,7 +238,7 @@ if($env:RUNNER -eq 'self-hosted' -or (-not($env:ImageOS) -and -not($env:ImageVer
Start-Sleep 1 Start-Sleep 1
exit 1 exit 1
} }
if ((Get-InstalledModule).Name -notcontains 'VcRedist') { if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) {
Install-Module -Name VcRedist -Force Install-Module -Name VcRedist -Force
} }
New-Item $php_dir -Type Directory -Force > $null 2>&1 New-Item $php_dir -Type Directory -Force > $null 2>&1
@ -275,7 +275,7 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
$status = "Installed" $status = "Installed"
$extra_version = "" $extra_version = ""
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) { if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') { if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1 Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
} }
try { try {