Private/Initialize-CustomAzVm.ps1
# Will be called in VM function Global:Initialize-CustomAzVm { [CmdletBinding()] <# .SYNOPSIS Initializes the newly created VM .DESCRIPTION ... #> param() process { Write-Host "Checking if NuGet is installed..." if (-not (Get-PackageProvider -ListAvailable | Where-Object { $_.Name -eq 'NuGet' })) { try { Write-Host "Installing NuGet..." Install-PackageProvider -Name NuGet -Confirm:$False -Force | Out-Null } catch [Exception] { Write-Host "Error installing NuGet" $_.message exit } } Write-Host "Checking if module Cloud.Ready.Software.NAV is installed..." if (-not (Get-Module -ListAvailable -Name Cloud.Ready.Software.NAV)) { try { Write-Host "Installing Module Cloud.Ready.Software.NAV..." Install-Module Cloud.Ready.Software.NAV -Scope AllUsers -Confirm:$false -Force -SkipPublisherCheck:$true } catch [Exception] { Write-Host "Error installing Module" $_.message exit } } } } |