winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Winget not working from PowerShell window elevated using Intune EPM

Open ricke65 opened this issue 2 years ago • 5 comments

Brief description of your issue

I am running Powershell as Admin, which I launched by using Intune Endpoint Privilege Manager (EPM). I am trying to run winget and it is not working.

Steps to reproduce

I open a Powershell Administrator session, by using the 'Run with Elevated Access' feature of Intune EPM

Intune EPM

When I then run winget.exe it gives an error

Expected behavior

winget runs normally, with Administrator privilege (because it was run with an elevated PowerShell session) and allows me to install/manage packages

Actual behavior

When I then try to run winget.exe it fails; when I first try to run it is unable to recognize the cmdlet. When I change to the location of winget.exe the error is different.

unable to recognize the cmdlet

PS C:\Windows\System32\WindowsPowerShell\v1.0> winget winget : The term 'winget' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • winget
  •   + CategoryInfo          : ObjectNotFound: (winget:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

PS C:\Windows\System32\WindowsPowerShell\v1.0>

When I change to the path where winget.exe is located, I get an access denied / NativeCommandFailed error:

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.1572.0_x64__8wekyb3d8bbwe> .\winget Program 'winget.exe' failed to run: Access is deniedAt line:1 char:1

  • .\winget

At line:1 char:1

  • .\winget
  •   + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
      + FullyQualifiedErrorId : NativeCommandFailed
    
    

PS C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.20.1572.0_x64__8wekyb3d8bbwe>

Environment

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

Windows: Windows.Desktop v10.0.22000.2057
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.20.1572.0

Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages

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

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
PS C:\Users\118258>

ricke65 avatar Jul 10 '23 01:07 ricke65

Winget Powershell Error 1 Winget Powershell Error 2

ricke65 avatar Jul 10 '23 04:07 ricke65

To reframe what I'm trying to do - what I want is to be able to use winget to install software, without giving people local admin rights.

Ideally, I would put apps in Intune Company Portal, but most of what I want is not in the MS Store repository (but a lot is in the Community Repository), and thus winget is unhelpful it seems

ricke65 avatar Jul 10 '23 06:07 ricke65

You might want to take a look at:

  • #3049

denelon avatar Jul 10 '23 16:07 denelon

@denelon This is great! I have managed to get winget working today. I installed PowerShell 7.3.5, then installed the winget Powershell module, and (re)installed winget from the elevated PowerShell session, and now it works!

Now we just need integration of the Community Repository with Intune...

ricke65 avatar Jul 11 '23 11:07 ricke65

@ricke65 Can you elaborate on how you were able to elevate winget.exe through EPM?

MarcoBuess avatar Aug 15 '24 10:08 MarcoBuess