forked from keithbabinec/SampleMsalAuthorizationCodeFlow
/
install-azure-prerequisites.ps1
42 lines (32 loc) · 1009 Bytes
/
install-azure-prerequisites.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[CmdletBinding()]
param
(
)
#Requires -RunAsAdministrator
$ErrorActionPreference = "Stop"
Write-Host "Checking for Azure CLI tooling prerequisite."
# install the Azure CLI tools
try
{
$null = az --version
$cliToolsInstalled = $true
}
catch [System.Management.Automation.CommandNotFoundException]
{
$cliToolsInstalled = $false
}
if ($cliToolsInstalled -eq $false)
{
Write-Host "Azure CLI tooling was not found. Installing the latest version now."
Write-Host "Downloading Azure CLI installer."
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi
Write-Host "Running Azure CLI installer."
Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'
Write-Host "Removing Azure CLI installer file."
Remove-Item .\AzureCLI.msi
Write-Host "Installation completed. You should restart PowerShell to ensure the 'az' commands are available in the path."
}
else
{
Write-Host 'Azure CLI tooling is already installed.'
}