Skip to content

Commit

Permalink
Better installing/importing of PS modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Koos Goossens committed Nov 28, 2022
1 parent 119a137 commit 1cb2f9a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions powershell-script/AzSentinelPricingOptimizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,21 @@ if ($updateArmParameters) {
)
Write-Host "Installing/Importing PowerShell modules..." -ForegroundColor DarkGray
$modulesToInstall | ForEach-Object {
if (-not (Get-Module -ListAvailable -All $_)) {
Write-Host "Module [$_] not found, installing..." -ForegroundColor DarkGray
if (-not (Get-Module -ListAvailable $_)) {
Write-Host " ┖─ Module [$_] not found, installing..." -ForegroundColor DarkGray
Install-Module $_ -Force
} else {
Write-Host " ┖─ Module [$_] already installed." -ForegroundColor DarkGray
}
}

$modulesToInstall | ForEach-Object {
Write-Host "Importing Module [$_]" -ForegroundColor DarkGray
Import-Module $_ -Force
if (-not (Get-InstalledModule $_)) {
Write-Host " ┖─ Module [$_] not loaded, importing..." -ForegroundColor DarkGray
Import-Module $_ -Force
} else {
Write-Host " ┖─ Module [$_] already loaded." -ForegroundColor DarkGray
}
}

# (Re-)setting Variables
Expand Down

0 comments on commit 1cb2f9a

Please sign in to comment.