-
-
Save mistyn8/a53828bdc6da9299836cfd4073d61d8e to your computer and use it in GitHub Desktop.
Install AzCopy on Windows (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
# ============================================================================= | |
# Install AzCopy on Windows (PowerShell) | |
# https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10 | |
# https://github.com/Azure/azure-storage-azcopy | |
# ----------------------------------------------------------------------------- | |
# Developer.......: Andre Essing (https://www.andre-essing.de/) | |
# (https://github.com/aessing) | |
# (https://twitter.com/aessing) | |
# (https://www.linkedin.com/in/aessing/) | |
# ----------------------------------------------------------------------------- | |
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, | |
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED | |
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. | |
# ============================================================================= | |
# Download and extract | |
Invoke-WebRequest -Uri "https://aka.ms/downloadazcopy-v10-windows" -OutFile AzCopy.zip -UseBasicParsing | |
Expand-Archive ./AzCopy.zip ./AzCopy -Force | |
# Move AzCopy | |
$location = "$env:LOCALAPPDATA\Programs\AZCopy" | |
if ( -Not (Test-Path -Path $location ) ) { New-Item $location -ItemType "Directory"} | |
Get-ChildItem -Path "./AzCopy/*/azcopy.exe" | Move-Item -Destination "$location" -Force | |
# Add AzCopy to PATH | |
$userenv = (Get-ItemProperty -Path 'HKCU:\Environment' -Name Path).path | |
$systemenv = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name Path).path | |
$newPath = "$location;" | |
IF ($userenv.Contains($newPath) || $systemenv.Contains($newPath) ) { | |
Write-Output "$newPath - already exists in local system or user path env var" | |
} | |
else { | |
Write-Output "$newPath - added to local user path env var" | |
New-ItemProperty -Path 'HKCU:\Environment' -Name Path -Value "$userenv$newPath" -Force | |
} | |
# Clean the kitchen | |
Remove-Item -Force AzCopy.zip | |
Remove-Item -Force -Recurse .\AzCopy\ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment