GithubHelp home page GithubHelp logo

asheroto / winget-install Goto Github PK

View Code? Open in Web Editor NEW
200.0 5.0 18.0 288 KB

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2022.

Home Page: https://bit.ly/winget-install

License: GNU General Public License v3.0

PowerShell 100.00%
automatically cli cmd installer powershell prerequisites winget xaml msix msixbundle

winget-install's Introduction

winget Windows 10

PowerShell Gallery Downloads GitHub Downloads - All Releases Release GitHub Release Date - Published_At

GitHub Sponsor Ko-Fi Button

Install winget from PowerShell

winget, a command line package manager, doesn't have a command line installer? 🤣 Now it does! 😊

Note

Microsoft released some new short URLs that work well for installing winget. This is the new script that is smaller and faster at installing winget!

Table of Contents

Requirements

  • Requires PowerShell running with Administrator rights
  • Compatible with:
    • Windows 10 (Version 1809 or higher)
    • Windows 11
    • Server 2022
    • Windows Sandbox
  • Not compatible with:
    • Server 2019 (winget not supported)

Features

  • Installs winget-cli directly from PowerShell
  • Always fetches the latest winget version
  • Automatically verifies OS compatibility
  • Determines and installs the appropriate prerequisites based on OS version
  • Supports x86/x64 and arm/arm64 architectures
  • Allows bypassing of existing winget installation verification through -Force parameter or $Force session variable
  • Supports irm/iex one-line command using short URL
  • Supports automatically relaunching in conhost and ending active processes associated with winget that could interfere with the installation
  • Code is hosted on PowerShell Gallery

Script Functionality

  • Identifies processor architecture to decide which prerequisites are needed (x86/x64 or arm/arm64)
  • Checks Windows OS version for compatibility (Windows 10, Windows 11, Server 2022)
  • Verifies Windows 10 release ID for compatibility (must be 1809 or newer)
  • Uses the UI.Xaml and VCLibs as recommended by Microsoft
  • The winget-cli license is downloaded using the latest version from GitHub
  • winget-cli is then installed using the latest version from GitHub
  • Runs command registration if the winget command is not detected at the end of installation

Setup

Method 1 - PowerShell Gallery

Tip

If you want to trust PSGallery so you aren't prompted each time you run this command, or if you're scripting this and want to ensure the script isn't interrupted the first time it runs...

Install-PackageProvider -Name "NuGet" -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

This is the recommended method, because it always gets the public release that has been tested, it's easy to remember, and supports all parameters.

Open PowerShell as Administrator and type

Install-Script winget-install -Force

Follow the prompts to complete the installation (you can tap A to accept all prompts or Y to select them individually.

Note: -Force is optional but recommended, as it will force the script to update if it is outdated. If you do not use -Force, it will not overwrite the script if outdated.

Usage

winget-install

If winget is already installed, you can use the -Force parameter to force the script to run anyway.

The script is published on PowerShell Gallery under winget-install.

Method 2 - One Line Command (Runs Immediately)

The URL asheroto.com/winget always redirects to the latest code-signed release of the script.

If you just need to run the basic script without any parameters, you can use the following one-line command:

Option A: asheroto.com short URL

irm asheroto.com/winget | iex

Due to the nature of how PowerShell works, you won't be able to use any parameters like -Force with this command line. You can set the global variable $Force to $true and the script should pick up on it (more info), but if for some reason that doesn't work or you absolutely need to use a one-line command with parameters, you can use the following:

&([ScriptBlock]::Create((irm asheroto.com/winget))) -Force

Option B: winget.pro short URL

To make it easier to remember, you can also use the URL winget.pro which redirects to the same URL. This URL is provided courtesy of Omaha Consulting.

irm winget.pro | iex

Due to the nature of how PowerShell works, you won't be able to use any parameters like -Force with this command line. You can set the global variable $Force to $true and the script should pick up on it (more info), but if for some reason that doesn't work or you absolutely need to use a one-line command with parameters, you can use the following:

&([ScriptBlock]::Create((irm winget.pro))) -Force

Option C: direct release URL

Alternatively, you can of course use the latest code-signed release URL directly:

irm https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 | iex

Method 3 - Download Locally and Run

As a more conventional approach, download the latest winget-install.ps1 from Releases, then run the script as follows:

.\winget-install.ps1

You can use the -Force or -ForceClose parameters if needed, or use $Force = $true and $ForceClose = $true global session variables if preferred.

Tip

If for some reason your PowerShell window closes at the end of the script and you don't want it to, or don't want your other scripts to be interrupted, you can wrap the command in a powershell "COMMAND HERE". For example, powershell "irm asheroto.com/winget | iex".

Parameters

No parameters are required to run the script, but there are some optional parameters to use if needed.

Parameter Description
-Debug Enables debug mode, which shows additional information for debugging.
-Force Ensures installation of winget and its dependencies, even if already present.
-ForceClose Windows Terminal sometimes has trouble installing winget; run the script with the -ForceClose parameter to relaunch the script in conhost.exe and automatically end active processes associated with winget that could interfere with the installation
-CheckForUpdate Checks if there is an update available for the script.
-Wait By default, the script will exit immediately after completion. If you need some time to observe the script output, you can use this parameter to force the script to pause for several seconds before exiting.
-UpdateSelf Updates the script to the latest version.
-Version Displays the version of the script.
-Help Displays the full help information for the script.

Example Parameters Usage

winget-install -Force

Global Variables

Global variables are optional and are only needed if you don't want to use parameters. They can be set before running the script, or you can set them in your PowerShell profile to always use them.

Variable Description
$Debug Enables debug mode, which shows additional information for debugging.
$Force Ensures installation of winget and its dependencies, even if already present.
$ForceClose Windows Terminal sometimes has trouble installing winget; run the script with the -ForceClose parameter to relaunch the script in conhost.exe and automatically end active processes associated with winget that could interfere with the installation

Example Global Variables Usage

$Force = $true
winget-install

Troubleshooting

  • Before releasing a new version, the script is tested on a clean install of Windows 10 22H2, Server 2022 21H2, and Windows 11 22H2.
  • If you run into an issue, please ensure your system is compatible & fully updated.
  • Sometimes PowerShell accidentally closes the window before you can read the output, so you can use the -Wait parameter to pause the script for a few seconds before exiting if this is happening on your system.
  • Try running winget-install again, sometimes the script will fail due to a temporary issue with the prerequisite server URLs.
  • Try using the -Debug parameters to see if it provides any additional information.
  • If you're getting a resource in use error message, run the script again with the -ForceClose parameter.
  • Try installing winget manually to see if the issue exists with winget itself.
  • If the issue occurs when installing winget manually, please open an issue on the winget-cli repo (unrelated to this script).
  • Check the winget-cli Troubleshooting Guide.
  • Note that winget does not support installing or running with the SYSTEM account. Our tests also reflect this issue - even if winget is installed, it won't run properly using the SYSTEM account.
  • If the problem only occurs when using this script, please open an issue here.

Contributing

If you'd like to help develop this project: fork the repo, edit the code, then submit a pull request. 😊

winget-install's People

Contributors

asheroto avatar misterzeus avatar og-mrk avatar thomasschadenhofer avatar uffemcev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

winget-install's Issues

some kind of problem when installing WinGet

I hit this error during the last steps, where the script tries to install winget:

PS C:\WINDOWS\system32> winget-install
##################################################

Downloading Xaml nupkg file...

##################################################

Downloading https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.4
Saving as: C:\Users\MyUser\AppData\Local\Temp\Microsoft.UI.Xaml.2.8.4.nupkg.zip

Expanding: C:\Users\MyUser\AppData\Local\Temp\Microsoft.UI.Xaml.2.8.4.nupkg.zip
Into: C:\Users\MyUser\AppData\Local\Temp\Microsoft.UI.Xaml.2.8.4

##################################################

Downloading & installing x64 VCLibs...

##################################################

##################################################

Installing x64 XAML...

##################################################

Installing Appx Packages In: C:\Users\MyUser\AppData\Local\Temp\Microsoft.UI.Xaml.2.8.4\tools\AppX\x64\Release

Installing Appx Package: Microsoft.UI.Xaml.2.8.appx

Retrieving download URL for winget from GitHub...

##################################################

Downloading winget...

##################################################

Downloading:
https://github.com/microsoft/winget-cli/releases/download/v1.4.11071/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Saving as: C:\Users\MyUser\AppData\Local\Temp\winget.msixbundle

Downloading:
https://github.com/microsoft/winget-cli/releases/download/v1.4.11071/5d9d44b170c146e1a3085c2c75fcc2c1_License1.xml
Saving as: C:\Users\MyUser\AppData\Local\Temp\license1.xml

##################################################

Installing winget...

##################################################

Installing package: C:\Users\MyUser\AppData\Local\Temp\winget.msixbundle

Something went wrong. Please try again or open an issue at https://github.com/asheroto/winget-install/issues
Line number: 251
Error: The parameter is incorrect.

Does this work on Server 2019/2022?

I tried this on Server 2019 and all the steps completed successfully, but winget is not recognized as a command. I believe Winget should be located at "C:\Program Files\WindowsApps" but that folder does not exist. Winget isn't officially supported for Server OSes, but there are workarounds and just want to confirm your script will accommodate the workarounds for servers.

No applicable app licenses found

When installing on a new Windows 2022 server the installation completes successfully, but winget will not run.

The issue seems to be caused by a missing license file:
image

The issue has earlier been reported in winget repo:
microsoft/winget-cli#700

The issue seems to be caused by the change where the script now uses Add-AppxPackage instead of Add-AppxProvisionedPackage:

Add-AppxPackage -Path $wingetPath -ErrorAction SilentlyContinue

Add-AppxPackage doesn't support adding a license file.
The PowerShell script only downloads the license file from Winget but never uses it.

I have locally changed the above mentioned line to:
Add-AppxProvisionedPackage -Online -PackagePath $wingetPath -LicensePath $wingetLicensePath -ErrorAction SilentlyContinue

and it works on the server I tested on

issue

WARNING! An error occurred during installation!

###################################################

WARNING: Something went wrong. If messages above don't help and the problem persists,
WARNING: Please open an issue at https://github.com/asheroto/winget-install/issues
WARNING: Line number : 434
WARNING: Error: Deployment failed with HRESULT: 0x80073CF6, Package could not be registered.

error 0xC0020036: windows.licensing failed to start ClipSvc. Try again and contact the package publisher if the problem
persists.

NOTE: For additional information, look for [ActivityId] 6531d6de-ce87-000a-5ee3-3e6587ced901 in the Event Log or use
the command line Get-AppPackageLog -ActivityID 6531d6de-ce87-000a-5ee3-3e6587ced901

does not work on server 2019 ( but it should )

Thank you for this. Great and very helpful. Any idea why it does not work for server 2019 as-is? ( It should .. )
BTW the following GIST from @likamrat (Lior Kamrat) does work for server 2019 also.

https://gist.github.com/likamrat/cae833a6e5b3461709f14c093c21c293

But I don't like his use of the "https://store.rg-adguard.net/api/GetFiles" to get some of the downloads ... I thought I post it here in case it helps you figure out why yours does not work on server 2019?

WINGET NOT INSTALLING

PS E:\Documents\scripts> winget-install.ps1

##########################################

Downloading & installing x64 VCLibs...

##########################################

##########################################

Downloading & installing x64 VCLibs...

##########################################

URL: https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx

###########################################

Downloading & installing x64 UI.Xaml...

###########################################

Downloading: https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3
Saving as: C:\Users\Akashdeep\AppData\Local\Temp\Microsoft.UI.Xaml.2.7.3.nupkg

###################################################

WARNING! An error occurred during installation!

###################################################

WARNING: Something went wrong. If messages above don't help and the problem persists,
WARNING: Please open an issue at https://github.com/asheroto/winget-install/issues
WARNING: Line number : 375
WARNING: Error: Unable to connect to the remote server

[Feature request]: Initializing winget without rebooting

What You Are Seeing?

Hello, it's me again! :)
After running the script on a freshly installed system I get this result:

Log Checking if winget is installed and working...

ПРЕДУПРЕЖДЕНИЕ: winget is installed but is not detected as a command. Try using winget now. If it doesn't work, wait about 1 minute and try again (it is sometimes delayed). Also try restarting your computer.

ПРЕДУПРЕЖДЕНИЕ: If you restart your computer and the command still isn't recognized, please read the Troubleshooting section
of the README: https://github.com/asheroto/winget-install#troubleshooting

ПРЕДУПРЕЖДЕНИЕ: Make sure you have the latest version of the script by running this command: winget-install -CheckForUpdate

PS C:\Users\uffemcev> winget
winget : Имя "winget" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличие и правильность пути, после чего повторите попытку.
строка:1 знак:1
+ winget
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (winget:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Even after installation via a script winget is still not initialized in the system. The problem can be solved by restarting the PC, but there is another way to solve this. Microsoft suggests using this command: Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe

After this the winget is ready for work instantly. So what do you think about this?

System Details

Script verson 3.0.1
Windows 22H2
UAC disable
Powershell 5.1
Run as administrator

Install as SYSTEM user

It seems there might be a limitation of using this script as the SYSTEM account. I don't know if this is a limitation of winget itself or the installer. If it's winget, you might consider to put a check in the install to check if it's being ran as SYSTEM. If not, could it be added?

[Bug]: default terminal application and powershell x86 issue

What You Are Seeing?

Another day - another bug :)

If i set default terminal application as windows terminal and run windows powershell (x86) so Get-CurrentProcessModuleName function will stop working because MainModule and Modules fields are empty. Is it the same for you?

I think function must check several properties at once, but not only MainModule.

bug example
Windows PowerShell
(C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.

Установите последнюю версию PowerShell для новых функций и улучшения! https://aka.ms/PSWindows

PS C:\Users\uffemcev> function Get-CurrentProcessModuleName {
>>     <#
>>         .SYNOPSIS
>>             Gets the module name of the current PowerShell process.
>>
>>         .DESCRIPTION
>>             This function retrieves the window title of the current PowerShell host, finds the corresponding process, and returns the name of the main module of that process without the file extension.
>>
>>         .EXAMPLE
>>             $processName = Get-CurrentProcessModuleName
>>             This example shows how to use the function to get the module name of the current process and store it in a variable.
>>
>>         .NOTES
>>             This function assumes that the window title is unique to the current PowerShell session. If multiple windows have the same title, the function may not behave as expected.
>>     #>
>>
>>     $windowTitle = $host.ui.RawUI.WindowTitle
>>     $currentProcess = Get-Process | Where-Object { $_.MainWindowTitle -eq $windowTitle }
>>     $moduleNameWithExtension = $currentProcess.MainModule.ModuleName
>>     $moduleNameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($moduleNameWithExtension)
>>     return $moduleNameWithoutExtension
>> }
PS C:\Users\uffemcev> Get-CurrentProcessModuleName

PS C:\Users\uffemcev> $windowTitle = $host.ui.RawUI.WindowTitle
PS C:\Users\uffemcev> $currentProcess = Get-Process | Where-Object { $_.MainWindowTitle -eq $windowTitle }
PS C:\Users\uffemcev> $currentProcess

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    809      43    92712      82484       0,08  11388   1 WindowsTerminal


PS C:\Users\uffemcev> $currentProcess | format-list *


Name                       : WindowsTerminal
Id                         : 11388
PriorityClass              : Normal
FileVersion                :
HandleCount                : 809
WorkingSet                 : 84463616
PagedMemorySize            : 94937088
PrivateMemorySize          : 94937088
VirtualMemorySize          : -1
TotalProcessorTime         : 00:00:00.0937500
SI                         : 1
Handles                    : 809
VM                         : 4294967295
WS                         : 84463616
PM                         : 94937088
NPM                        : 44152
Path                       :
Company                    :
CPU                        : 0,09375
ProductVersion             :
Description                :
Product                    :
__NounName                 : Process
BasePriority               : 8
ExitCode                   :
HasExited                  : False
ExitTime                   :
Handle                     : 3440
SafeHandle                 : Microsoft.Win32.SafeHandles.SafeProcessHandle
MachineName                : .
MainWindowHandle           : 1574456
MainWindowTitle            : Администратор: Windows PowerShell (x86)
MainModule                 :
MaxWorkingSet              : 1413120
MinWorkingSet              : 204800
Modules                    :

System Details

Script verson 3.2.2
Windows 11 22H2
UAC disable
Powershell 5.1
Run as administrator

[Feature request]: Automation of closing conflicting processes during installation

What You Are Seeing?

Hello again. This time I had a problem during installation: "The modified resources are in use. Try closing Windows Terminal/PowerShell/Command Prompt and try again." This problem affects many other applications that interfere with installation: store, notepad, webexperience, and so on. These processes often hang in the background and have to be closed through the task manager. Restarting the PC does not always help.

Example

ПРЕДУПРЕЖДЕНИЕ: Resources modified are in-use. Try closing Windows Terminal / PowerShell / Command Prompt and try again.
ПРЕДУПРЕЖДЕНИЕ: If the problem persists, restart your computer.
Add-AppxPackage : Сбой развертывания с HRESULT: 0x80073D02, Не удалось установить пакет, так как изменяемые им ресурсы в настоящее время используются.

Ошибка 0x80073D02: не удалось выполнить установку, так как требуется закрыть следующие приложения: Microsoft.WindowsNotepad_11.2307.27.0_x64__8wekyb3d8bbwe MicrosoftWindows.Client.WebExperience_423.23500.0.0_x64__cw5n1h2txyewy.

ПРИМЕЧАНИЕ. Чтобы получить дополнительные сведения, найдите [ActivityId] 9eea3719-0014-000a-9100-eb9e1400da01 в журнале событий или введите в командной строке Get-AppxLog -ActivityID 9eea3719-0014-000a-9100-eb9e1400da01.

строка:680 знак:9
+ Add-AppxPackage $url -ErrorAction Stop
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (http://tlu.dl.d...q2KJ%2fSg%3d%3d:String) [Add-AppxPackage], Exception
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

I would like to suggest using the "-ForceApplicationShutdown" parameter with all Add-AppxPackage cmdlets to automatically shut down conflicting processes. More about this: https://learn.microsoft.com/en-us/powershell/module/appx/add-appxpackage?view=windowsserver2022-ps#-forceapplicationshutdown

What do you think about this?

System Details

Script verson 3.1.1
Windows 11 22H2
UAC disable
Powershell 5.1
Run as administrator

Error when installing

Hello. I have winget, but I decided to run this script to test it and I get this error. The error appears if the system language is Russian. If the system language is English, then there is no problem. Sorry for bad English.

Script verson 3.0.0
Windows 22H2
UAC disable
Powershell 5.1
Run as admin

Log Windows PowerShell (C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.

Установите последнюю версию PowerShell для новых функций и улучшения! https://aka.ms/PSWindows

PS C:\Users\uffemcev> &([ScriptBlock]::Create((irm https://raw.githubusercontent.com/asheroto/winget-install/master/winget-install.ps1))) -Force
winget-install 3.0.0

###################################################
# Downloading & installing 64-разрядная VCLibs... #
###################################################

URL:

Installing 64-разрядная VCLibs...
ПРЕДУПРЕЖДЕНИЕ: Error when trying to download or install VCLibs. Trying alternate method...

Installing 64-разрядная VCLibs...
ПРЕДУПРЕЖДЕНИЕ: Same version already installed.
ПРЕДУПРЕЖДЕНИЕ: That's okay, continuing...

####################################################
# Downloading & installing 64-разрядная UI.Xaml... #
####################################################

URL:

Installing 64-разрядная UI.Xaml...
ПРЕДУПРЕЖДЕНИЕ: Error when trying to download or install UI.Xaml. Trying alternate method...

Downloading UI.Xaml...
Extracting...

Installing 64-разрядная UI.Xaml...
Get-ChildItem : Не удается найти путь "C:\Users\uffemcev\AppData\Local\Temp\Microsoft.UI.Xaml.2.7.3\tools\AppX\64-разрядная\Release\Microsoft.UI.Xaml.2.7.appx", так как он не существует.
строка:706 знак:17
+ ... Get-ChildItem -Path $XamlAppxPath -Filter *.appx | ForEa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\uffemc...I.Xaml.2.7.appx:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

UI.Xaml installed successfully.

######################################
# Downloading & installing winget... #
######################################

Retrieving download URL for winget from GitHub...
Downloading winget...
Downloading license...

Installing winget...

winget installed successfully.

#################################################################################################
# Checking and adding WindowsApps directory to PATH variable for current user if not present... #
#################################################################################################

PATH variable already present for Machine, skipping.
PATH variable already present for User, skipping.

##########################
# Installation complete! #
##########################

Checking if winget is installed and working...
winget is installed and working now, you can go ahead and use it.
PS C:\Users\uffemcev>

[Bug]: Fails during Registering step

Checklist

  • I have performed the steps in the Troubleshooting section and confirm that the issue only occurs with this script.

  • I have restarted my computer to confirm this is not a transitory problem.

  • I have verified that I am using the latest version of winget-install.

  • I have verified that this issue is NOT security related (please create security advisory if so).

  • I have run the script with the -DebugMode argument and included the output below

What You Are Seeing?

###############

Registering

###############

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates, dependency or conflict validation.
Windows cannot install package Microsoft.DesktopAppInstaller_1.22.10582.0_x64__8wekyb3d8bbwe because this package depends on a framework that could not be found. Provide the framework
"Microsoft.UI.Xaml.2.8" published by "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor architecture and minimum version
8.2310.30001.0, along with this package to install. The frameworks with name "Microsoft.UI.Xaml.2.8" currently installed are: {}
NOTE: For additional information, look for [ActivityId] f6859c66-6b2d-0006-36da-85f62d6bda01 in the Event Log or use the command line Get-AppPackageLog -ActivityID
f6859c66-6b2d-0006-36da-85f62d6bda01
At C:\Program Files\WindowsPowerShell\Scripts\winget-install.ps1:829 char:13
+             Add-AppxPackage -RegisterByFamilyName -MainPackage Micros ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Deskt...r_8wekyb3d8bbwe:String) [Add-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageComman

System Details

Windows 10 Pro x64 22H2

Additional Context

Just started 2/27/24.

Full Output With -DebugMode

`Name Value


PSVersion 5.1.19041.3803
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3803
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Name : ConsoleHost
Version : 5.1.19041.3803
InstanceId : 6b9ff3ac-41c9-49c1-be6b-d61ef09a6d4a
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

winget-install 4.0.2
To check for updates, run winget-install -CheckForUpdate
VERBOSE: Perform operation 'Enumerate CimInstances' with following parameters, ''namespaceName' = root\cimv2,'className' = Win32_OperatingSystem'.
VERBOSE: Operation 'Enumerate CimInstances' complete.

#################

Prerequisites

#################

Downloading VCLibs...
VERBOSE: GET https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx with 0-byte payload
VERBOSE: received 6764349-byte response of content type application/octet-stream
Downloading UI.Xaml...
VERBOSE: GET https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.7.3/Microsoft.UI.Xaml.2.7.x64.appx with 0-byte payload
VERBOSE: received 5070706-byte response of content type application/octet-stream

##########

winget

##########

VERBOSE: GET https://api.github.com/repos/microsoft/winget-cli/releases with 0-byte payload
VERBOSE: received 449422-byte response of content type application/json; charset=utf-8
Downloading winget license...
VERBOSE: GET https://github.com/microsoft/winget-cli/releases/download/v1.7.10582/5e4a105df01840b0bbf00985e4f57c1e_License1.xml with 0-byte payload
VERBOSE: received 2688-byte response of content type application/octet-stream
Downloading winget...
VERBOSE: GET https://aka.ms/getwinget with 0-byte payload
VERBOSE: received 258178004-byte response of content type application/octet-stream
Installing winget and its dependencies...
VERBOSE: Target Image Version 10.0.19045.3803

############

Complete

############

winget installed successfully.
Checking if winget is installed and working...

###############

Registering

###############

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates, dependency or conflict validation.
Windows cannot install package Microsoft.DesktopAppInstaller_1.22.10582.0_x64__8wekyb3d8bbwe because this package depends on a framework that could not be found. Provide the framework
"Microsoft.UI.Xaml.2.8" published by "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor architecture and minimum version
8.2310.30001.0, along with this package to install. The frameworks with name "Microsoft.UI.Xaml.2.8" currently installed are: {}
NOTE: For additional information, look for [ActivityId] f6859c66-6b2d-0006-07de-85f62d6bda01 in the Event Log or use the command line Get-AppPackageLog -ActivityID
f6859c66-6b2d-0006-07de-85f62d6bda01
At C:\Program Files\WindowsPowerShell\Scripts\winget-install.ps1:829 char:13

  •         Add-AppxPackage -RegisterByFamilyName -MainPackage Micros ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : WriteError: (Microsoft.Deskt...r_8wekyb3d8bbwe:String) [Add-AppxPackage], IOException
    • FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

VERBOSE: Operation completed for: Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
winget command registered successfully.`

[Bug]: Get-OSInfo incorrectly identifies Windows 11 23H2 Multi-Session as a Server OS < 2022

Checklist

  • I have performed the steps in the Troubleshooting section and confirm that the issue only occurs with this script.

  • I have restarted my computer to confirm this is not a transitory problem.

  • I have verified that I am using the latest version of winget-install.

  • I have verified that this issue is NOT security related (please create security advisory if so).

  • I have run the script with the -DebugMode argument and included the output below

What You Are Seeing?

Running the script on Windows 11 23H2 Enterprise multi-session (for Azure Virtual Desktop) Azure Marketplace image. The script returns this error:

winget requires Windows Server 2022 or newer on server platforms. Your version of Windows Server is not supported.

Running with -Force or -Debug returns same error.

I think the problem is the EditionID is ServerRdsh.

System Details

Azure Marketplace image:
Windows 11 (23H2) Enterprise multi-session + Microsoft 365 Apps - Gen2 (multi-session)
February Windows update installed
See Additional Context for details

Additional Context

PS C:> $osDetails = Get-CimInstance -ClassName Win32_OperatingSystem
PS C:> $osDetails
SystemDirectory Organization BuildNumber RegisteredUser SerialNumber Version


C:\Windows\system32 22631 00432-70000-00001-AA416 10.0.22631

PS C:> Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
SystemRoot : C:\Windows
BaseBuildRevisionNumber : 1
BuildBranch : ni_release
BuildGUID : ffffffff-ffff-ffff-ffff-ffffffffffff
BuildLab : 22621.ni_release.220506-1250
BuildLabEx : 22621.1.amd64fre.ni_release.220506-1250
CompositionEditionID : Enterprise
CurrentBuild : 22631
CurrentBuildNumber : 22631
CurrentMajorVersionNumber : 10
CurrentMinorVersionNumber : 0
CurrentType : Multiprocessor Free
CurrentVersion : 6.3
DisplayVersion : 23H2
EditionID : ServerRdsh
EditionSubManufacturer :
EditionSubstring :
EditionSubVersion :
InstallationType : Client
InstallDate : 1709571506
ProductName : Windows 10 Enterprise multi-session
ReleaseId : 2009
SoftwareType : System
UBR : 3155
PathName : C:\Windows
PendingInstall : 0
ProductId : 00432-70000-00001-AA416
DigitalProductId : {164, 0, 0, 0...}
DigitalProductId4 : {248, 4, 0, 0...}
InstallTime : 133540451065555457
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT
PSChildName : CurrentVersion
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry

Full Output With -DebugMode

No response

Errors when installing

Script verson 1.0.1
Windows 22H2
UAC disable
Powershell 5.1
Run as admin

Log PS C:\Users\uffemcev> iwr raw.githubusercontent.com/asheroto/winget-installer/master/winget-install.ps1 | iex

Invoke-RestMethod : BlobNotFoundThe specified blob does not exist.
RequestId:68001a83-a01e-0069-2c38-a384bb000000
Time:2023-06-20T05:31:37.0098866Z
At line:47 char:10
+ $json = Invoke-RestMethod -Method Get -Uri $url
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Cannot index into a null array.
At line:49 char:2
+ $latestVersion = $json.versions[-1]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

##################################################
# Downloading Xaml nupkg file...
##################################################

##################################################
# Downloading & installing x64 VCLibs...
##################################################

##################################################
# Installing x64 XAML...
##################################################

Add-AppxPackage : Cannot find path 'C:\Users\uffemcev\AppData\Local\Temp\Microsoft.UI.Xaml.\tools\AppX\x64\Release\Microsoft.UI.Xaml..appx' because it does not exist.
At line:69 char:2
+ Add-AppxPackage $pkg -ErrorAction SilentlyContinue
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\uffemc...t.UI.Xaml..appx:String) [Add-AppxPackage], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

##################################################
# Downloading winget...
##################################################

##################################################
# Installing winget...
##################################################

##################################################
# Checking and adding WindowsApps directory to PATH variable for current user if not present...
##################################################

##################################################
# Cleaning up...
##################################################

Remove-Item : An object at the specified path C:\Users\uffemcev\AppData\Local\Temp\Microsoft.UI.Xaml. does not exist.
At line:148 char:1
+ Remove-Item -Path $nupkgFolder -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Remove-Item], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RemoveItemCommand

##################################################
# Installation complete!
##################################################

##################################################
# Please restart your computer to complete the installation.
##################################################

PS C:\Users\uffemcev>

[Request]: -NoExit argument

Describe the feature or improvement you're requesting

Hello! We know that when restarting in conhost from the terminal with -ForceClose param, the script window automatically closes after completion.

Now I'm see that this behavior exists even in normal mode without a restarting with -ForceClose param. So for example this won't work:

test.ps1

&([ScriptBlock]::Create((irm https://raw.githubusercontent.com/uffemcev/winget-install/master/winget-install.ps1))) -Force; dir; pause

Perhaps it makes sense to add a -NoExit param that would disable automatic exit after completion.

Of course, this still probably won't work after restarting from Terminal in Conhost with -ForceClose param, but the script warns about this, so it's okay.

Additional context

No response

[Bug]: SYSTEM user will not run Add-AppxPackage, winget will not install properly

Checklist

  • I have performed the steps in the Troubleshooting section and confirm that the issue only occurs with this script.

  • I have restarted my computer to confirm this is not a transitory problem.

  • I have verified that I am using the latest version of winget-install.

  • I have verified that this issue is NOT security related (please create security advisory if so).

  • I have run the script with the -DebugMode argument and included the output below

What You Are Seeing?

I am running winget-install as the system user, and the system user is not allowed to run the Add-AppxPackage command. Also, WinGet will not run properly as the SYSTEM user after install, even if I run it directly from the C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.22.11132.0_x64__8wekyb3d8bbwe directory.

System Details

image

Additional Context

I am trying to implement this into the RMM software I use at my workplace, so we can utilize WinGet as our package management solution.

Full Output With -DebugMode

PS C:\Windows\system32> winget-install -Force -DebugMode
C:\Program Files\WindowsPowerShell\Scripts\winget-install.ps1 : A parameter cannot be found that matches parameter 
name 'DebugMode'.
At line:1 char:23
+ winget-install -Force -DebugMode
+                       ~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [winget-install.ps1], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,winget-install.ps1
 
PS C:\Windows\system32> winget-install -Force -Debug
winget-install 4.0.4
To check for updates, run winget-install -CheckForUpdate

#################
# Prerequisites #
#################

Downloading VCLibs...
DEBUG: Downloading VCLibs from https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx to C:\Windows\TEMP\bnazp150.tyi

Downloading UI.Xaml...
DEBUG: Downloading UI.Xaml from 
https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx to
C:\Windows\TEMP\uu0i0mci.3kg

##########
# winget #
##########

DEBUG: Getting latest release...
Downloading winget license...
DEBUG: Downloading winget license from 
https://github.com/microsoft/winget-cli/releases/download/v1.7.11132/ccfd1d114c9641fc8491f3c7c179829e_License1.xml to
C:\Windows\TEMP\keuzlq30.itj

Downloading winget...
DEBUG: Downloading winget from https://aka.ms/getwinget to C:\Windows\TEMP\31k4bfcf.qhd

Installing winget and its dependencies...

############
# Complete #
############

winget installed successfully.
Checking if winget is installed and working...

###############
# Registering #
###############

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF9, Install failed. Please contact your software vendor. 
(Exception from HRESULT: 0x80073CF9)
Deployment Register operation rejected on package Microsoft.DesktopAppInstaller_2024.423.111.0_neutral_~_8wekyb3d8bbwe 
from: AppxBundleManifest.xml install request because the Local System account is not allowed to perform this operation.
NOTE: For additional information, look for [ActivityId] 726e93c7-9819-0000-1185-6f721998da01 in the Event Log or use 
the command line Get-AppPackageLog -ActivityID 726e93c7-9819-0000-1185-6f721998da01
At C:\Program Files\WindowsPowerShell\Scripts\winget-install.ps1:836 char:13
+             Add-AppxPackage -RegisterByFamilyName -MainPackage Micros ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Deskt...r_8wekyb3d8bbwe:String) [Add-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand
 
winget command registered successfully.

[Bug]: one-liner and conhost issue

What You Are Seeing?

Hello again! :)

So if i use iex "& { $(iwr asheroto.com/winget) } -Force -ForceClose" command in Windows Terminal it's restarting in conhost and then it's immediately crash with error: there are no terminator "@>" in multiline comments. I can only assume that the problem is formatting, but I'm not sure.

In otherside there is no problem with &([ScriptBlock]::Create((irm asheroto.com/winget))) -Force -ForceClose command.

Video and photo examples. Is it the same for you?

System Details

Script verson 3.2.2
Windows 11 22H2
UAC disable
Powershell 5.1
Run as administrator

License

What is the license for this project?

Winget not installing

I've tried to run the script on several PCs. Not had any issues historically until yesterday. Now I just can't get winget to install. I get the same output as the readme. Failed getting latest UI.Xaml... Using hardcoded version 2.8.4 etc

However, despite many reboots, I just cannot get winget to install anymore.

I've tried 3 different builds on Windows 10 (Windows 10 Education - 22H2)

  1. Custom ISO updated to April 2023 (NTLite)
  2. Custom ISO updated to July 2023 (NTLite)
  3. Untouched ISO downloaded directly from VLSC - Updated July 2023

Also tried forcing the install using Chris Titus' script and I just get the message "Winget install failed".

Any ideas?

Suggestion to always get the newest version of winget from github

function getNewestLink($match){
$uri = "https://api.github.com/repos/microsoft/winget-cli/releases"
Write-Verbose "[$((Get-Date).TimeofDay)] Getting information from $uri"
$get = Invoke-RestMethod -uri $uri -Method Get -ErrorAction stop
Write-Verbose "[$((Get-Date).TimeofDay)] getting latest release"
$data = $get[0].assets | Where-Object name -Match $match
return $data.browser_download_url
}

$wingetUrl=getNewestLink("msixbundle")
$wingetLicenseUrl=getNewestLink("License1.xml")

[Bug]: current setup will not work inside winrm.

Checklist

  • I have performed the steps in the Troubleshooting section and confirm that the issue only occurs with this script.

  • I have restarted my computer to confirm this is not a transitory problem.

  • I have verified that I am using the latest version of winget-install.

  • I have verified that this issue is NOT security related (please create security advisory if so).

  • I have run the script with the -DebugMode argument and included the output below

What You Are Seeing?

While winget will install with this script with winrm. it is not useable.
any attempt to use winget via winrm will be unable to actually update source lists & unable to accept any source agreement.

someone documented an alternative method of setup here: microsoft/winget-cli#256 (comment)

it would be nice if this method could be included in the winget-install script as an alternative install method flag for people wanting to use winget via winrm.

System Details

windows 2k22 server latest

issue detected when setting up an os with packer which uses winrm to manage the VM its building out

Additional Context

No response

Full Output With -DebugMode

due to the packer setup its quite difficult for me to get these logs as the build fails and the VM is deleted

Check if WinGet is installed

Would be nice to add some code to get if WinGet is installed - and if so is it the latest version.

If WinGet is installed, and it's the latest version, just write it and exit.
If not installed or not latest version install/update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.