Skip to content

Instantly share code, notes, and snippets.

@phyoewaipaing
Last active March 26, 2024 05:43
Show Gist options
  • Save phyoewaipaing/389928fa29dc8ede3798472aebdf7de6 to your computer and use it in GitHub Desktop.
Save phyoewaipaing/389928fa29dc8ede3798472aebdf7de6 to your computer and use it in GitHub Desktop.
Function to add Winget Executable Path to the current powershell session variable
function Add-WinGetPath {
$WinGetPath = (Get-ChildItem -Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller*_x64*\winget.exe").DirectoryName
If (-Not(($Env:Path -split ';') -contains $WinGetPath))
{
If ($env:path -match ";$")
{
$env:path += $WinGetPath + ";"
}
else
{
$env:path += ";" + $WinGetPath + ";"
}
write-host "Winget path $WinGetPath added to environment variable"
}
else
{
write-host "Winget path already exists in registry."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment