Created
October 14, 2022 16:12
-
-
Save sengiv/767e97c2a8b1563cf916c407d04d2fa6 to your computer and use it in GitHub Desktop.
When run will add a directory to cmd/powershell PATH, so for example this code will make azcopy command available in terminal
This file contains hidden or 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
$InstallPath = 'C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy' | |
# Add InstallPath to the System Path if it does not exist | |
if ($env:PATH -notcontains $InstallPath) { | |
$path = ($env:PATH -split ";") | |
if (!($path -contains $InstallPath)) { | |
$path += $InstallPath | |
$env:PATH = ($path -join ";") | |
$env:PATH = $env:PATH -replace ';;', ';' | |
} | |
[Environment]::SetEnvironmentVariable("Path", ($env:path), [System.EnvironmentVariableTarget]::Machine) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment