Created
October 6, 2017 22:28
-
-
Save PlagueHO/cf9ed6c3fcadb4db6152ef1e1f18f791 to your computer and use it in GitHub Desktop.
Install Azure CLI 2.0 Nightly Build on Windows using Chocolatey and PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Install Azure CLI 2.0 Nightly Build on Windows using Chocolatey and PowerShell | |
#> | |
if (-not (Get-Command -Name Choco -ErrorAction SilentlyContinue)) | |
{ | |
Throw 'Chocolatey is not installed. Please install it. See https://chocolatey.org/install for instructions.' | |
} | |
Write-Host -Object 'Installing Python 3 with Chocolatey...' | |
& choco @('install','python3','-y') | |
Update-SessionEnvironment | |
$pyhtonScriptsPath = Join-Path -Path $ENV:APPDATA -ChildPath 'Python\Python36\Scripts' | |
$currentPath = [System.Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::User) -split ';' | |
if ($currentPath -notcontains $pyhtonScriptsPath) | |
{ | |
Write-Host -Object 'Adding Python Scripts to User Environment Path...' | |
$newPath = @() | |
$newPath += $currentPath | |
$newPath += $pyhtonScriptsPath | |
$newPathJoined = $newPath -join ';' | |
[System.Environment]::SetEnvironmentVariable('Path',$newPathJoined,[System.EnvironmentVariableTarget]::User) | |
} | |
if (-not $currentPath.Contains($pyhtonScriptsPath)) | |
{ | |
Write-Host -Object 'Adding Python Scripts to Current PowerShell session path...' | |
$ENV:Path = "$($ENV:Path);$pyhtonScriptsPath" | |
} | |
Write-Host -Object 'Installing nightly build of Az CLI 2.0...' | |
& pip @('install','--no-cache-dir','--user','--upgrade','--pre','azure-cli','--extra-index-url','https://azureclinightly.blob.core.windows.net/packages') | |
Write-Host -Object 'Installation of nightly build of Az CLI 2.0 complete. Execute "az" to start.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment