microsoft / microsoft/winget-cli

WinGet can't be run by different user than Administrator

Open
#2,721 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Feature
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

Hello,

I'm currently setting up an software deployment tool in our company.
I'd like to use winget to install the newest software and deploy the configuration (if needed) of the requested software by script, but actually that doesn't matter right now.

If I'm the end user and start a installation, the context of the installation will be run by the "NT AUTHORITY\System" user. To get a normal and good connection to the Domain I'm using, I'm starting a PSSession with a specific user. (The user is a local Administrator)

`function Change-Active-User {
$user = "Domain-NET.int\my_user"

$Key = ** my decryption key here

$new_pass = Get-Content '\\SERVER01\Hidden_Share$\Files\Scripts\Helper\my_pass_file.txt' | ConvertTo-SecureString -Key $Key

$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $new_pass

Start-Service -Name WinRM

$loginstall_session = New-PSSession -Credential $creds

}`

After that I run the "Change-Active-User" in my main script. To now run the Installation of winget remotely I use the "Invoke-Command" cmdlet:

`Invoke-Command -Session $my_session{
param($winget_dir, $vclibs_uwpdesktop, $vclibs, $ui_xaml, $winget, $winget_license)

_some commands to mount a smb share_

Start-Sleep -Seconds 3

Add-ProvisionedAppxPackage -Online -SkipLicense -PackagePath L:\$vclibs_uwpdesktop

Add-ProvisionedAppxPackage -Online -SkipLicense -PackagePath L:\$vclibs

Add-ProvisionedAppxPackage -Online -SkipLicense -PackagePath L:\$ui_xaml

Add-AppxPackage -Register -Path $winget

Add-ProvisionedAppxPackage -Online -SkipLicense -PackagePath L:\$winget

Add-AppxProvisionedPackage -Online -PackagePath L:\$winget -LicensePath L:\$winget_license

net use L: /delete`

After all this code, winget is installed.

Steps to reproduce

Install Win-Get as Appx Package, and try to run it through a pssession or a invoke-command or even with the NT Authority\SYSTEM User.

Expected behavior

Now the problem is, If I am the normal Administrator logged in from my test-domain (DOMAIN-NET.int) I can normally run the winget command:

image

Actual behavior

If I try to run it in the SYSTEM-User context, I get following error:
image

When I Enter the opened PSSession and am logged it with the domain user (as local admin), I get following error:

image

And yes the user is local administrator
image

Environment
EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR

PS C:\Users\Administrator> winget --info
Windows Package Manager v1.3.2691
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19044.1288
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.18.2691.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale


-----
Get-AppxProvisionedPackage
DisplayName  : Microsoft.DesktopAppInstaller
Version      : 2022.927.3.0
Architecture : neutral
ResourceId   : ~
PackageName  : Microsoft.DesktopAppInstaller_2022.927.3.0_neutral_~_8wekyb3d8bbwe
Regions


-----

PS C:\Users\Administrator> Get-AppxPackage Microsoft.DesktopAppInstaller


Name              : Microsoft.DesktopAppInstaller
Publisher         : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture      : X64
ResourceId        :
Version           : 1.18.2691.0
PackageFullName   : Microsoft.DesktopAppInstaller_1.18.2691.0_x64__8wekyb3d8bbwe
InstallLocation   : C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.18.2691.0_x64__8wekyb3d8bbwe
IsFramework       : False
PackageFamilyName : Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
PublisherId       : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle          : False
IsDevelopmentMode : False
NonRemovable      : False
Dependencies      : {Microsoft.UI.Xaml.2.7_7.2208.15002.0_x64__8wekyb3d8bbwe,
                    Microsoft.VCLibs.140.00.UWPDesktop_14.0.30704.0_x64__8wekyb3d8bbwe,
                    Microsoft.DesktopAppInstaller_1.18.2691.0_neutral_split.scale-100_8wekyb3d8bbwe}
IsPartiallyStaged : False
SignatureKind     : Store
Status            : Ok


EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR
EXECUTED AS DOMAIN-NET\ADMINISTRATOR

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure from a PowerShell remoting session and under NT AUTHORITY\SYSTEM, using the reported WinGet version and the attached command output. Check the resulting WinGet diagnostic logs under %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir. Done means the supported behavior for non-interactive users is established and the issue is fixed or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, powershell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.