-
-
Save phyoewaipaing/74d49c9d90ac99ca61836ea0f2c0b063 to your computer and use it in GitHub Desktop.
Powershell Script to install winget cli
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
##################################################################################################################### | |
## This script will download the winget package from github and install if the winget is not present on the system ## | |
##################################################################################################################### | |
$url = "https://github.com/microsoft/winget-cli/releases/download/v1.7.10861/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" | |
$outputFilePath = "C:\Temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" | |
############### Script Action Starts Here ############### | |
If ([string]::IsNullOrEmpty((Get-ChildItem -Path $env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller*_x64*\winget.exe))) | |
{ | |
"Winget is not found. So, will be installed" | |
# Remove if there is an existing downloaded file # | |
If (Test-Path -Path $outputFilePath) | |
{ | |
Remove-Item -Path $outputFilePath -Force | |
} | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# Download the MSIX bundle | |
Invoke-WebRequest -Uri $url -OutFile $outputFilePath | |
# Install the downloaded MSIX bundle | |
Add-AppxPackage -Path $outputFilePath | |
} | |
else | |
{ | |
"Winget already installed" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment