Created
April 13, 2015 18:33
-
-
Save ChaseFlorell/8df5bbaa1131cd16d4c6 to your computer and use it in GitHub Desktop.
Add a path to your $env:PATH
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
function Add-ToPath{ | |
param( | |
[parameter(Mandatory=$true,position=0)][string] $pathToAdd | |
) | |
if(-NOT ($env:path.Contains($pathToAdd))) | |
{ | |
Write-Host "Adding '$pathToAdd' to your Environment Path." | |
$env:path += ";$pathToAdd" | |
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $env:path | |
} else { | |
Write-Host "Your environment already contains '$pathToAdd'." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment