From 26d777592ec233cf1f1a70c3d389671ccd3709a1 Mon Sep 17 00:00:00 2001 From: msJinLei Date: Tue, 7 Feb 2023 21:44:58 +0800 Subject: [PATCH] Fix ThreadJob installation error of smoke test --- tools/Test/SmokeTest/InstallAzModules.ps1 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/Test/SmokeTest/InstallAzModules.ps1 b/tools/Test/SmokeTest/InstallAzModules.ps1 index f82a55990424..644de167b1a7 100644 --- a/tools/Test/SmokeTest/InstallAzModules.ps1 +++ b/tools/Test/SmokeTest/InstallAzModules.ps1 @@ -43,12 +43,20 @@ Register-Gallery $gallery $localRepoLocation Write-Host "Installing Az..." Install-Module -Name Az -Repository $gallery -Scope CurrentUser -AllowClobber -Force -$file = Get-ChildItem $localRepoLocation | Where-Object {$_.Name -like "ThreadJob*"} -$installedModule = Get-Module -ListAVailable -Name ThreadJob -if ($file -ne $null -and $installedModule -eq $null) { - Write-Host "Install ThreadJob..." - Install-Module -Name ThreadJob -Repository $gallery -Scope CurrentUser -AllowClobber -Force +if ($PSVersionTable.PSEdition -eq 'Desktop') { + $installedModule = Get-Module -ListAVailable -Name ThreadJob + if ($installedModule -eq $null) { + try { + Install-Module -Name ThreadJob -Repository $gallery -Scope CurrentUser -AllowClobber -Force + Write-Host "Install ThreadJob successfully." + } + catch { + Write-Host "Fail to install ThreadJob from ${gallery}." + Write-Host $_ + } + } } + # Check version Import-Module -MinimumVersion '2.6.0' -Name 'Az' -Force