Skip to content

Instantly share code, notes, and snippets.

@sengiv
Created October 14, 2022 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sengiv/767e97c2a8b1563cf916c407d04d2fa6 to your computer and use it in GitHub Desktop.
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
$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