Search code examples
windowspowershellwindows-10winget

Install winget by the command line (powershell)


I'm trying to write a PowerShell script to setup windows dev machines. I want to use winget but I don't see any easy way just to install winget using the commandline. You have to either use the windows store or download the msxibundle from github.

Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.3.2691/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile .\MicrosoftDesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Both of these require user's interaction instead of just running the script and walking away. Is there a better way? Thanks.


Solution

  • After having downloaded your msixbundle into .\MicrosoftDesktopAppInstaller_8wekyb3d8bbwe.msixbundle, you can install it using Windows PowerShell (not PowerShell Core), there's a command to help: Add-AppXPackage:

    Add-AppXPackage -Path .\MicrosoftDesktopAppInstaller_8wekyb3d8bbwe.msixbundle
    

    Should allow you to install the package you downloaded.

    Hope this helps