winget is not recognized as the name of cmdlet

Pavel yannara Mirochnitchenko 12,786 Reputation points MVP
2023-06-14T11:44:35.61+00:00

If I try to execute winget as admin, I will get error saying "winget is not recognized as the name of cmdlet" This is seeing on any Windows 11 computer. I already checked variable below. Is the any way to archive this? Because Intune new Store does not contain all apps yet, I am scripting some packages do get installed via WinGet. Application would work if User Context is used, but not with System context.

This problem is seeing only in Windows 11, Windows 10 does not have this problem. Also App Installer from Store is installed, it does not make any difference.

User's image

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,783 questions
Microsoft Intune Application management
Microsoft Intune Application management
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.Application management: The process of creating, configuring, managing, and monitoring applications.
982 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Khaled Elsayed Mohamed 1,325 Reputation points
    2023-06-15T10:16:13.4266667+00:00

    Hi Pavel

    I ran into this problem a while ago and the solution was to write down the file path, check my below script:

    #upgrade Microsoft Teams 
    #Date 20/9/2022
    #this script working with windows 10
    #this script working with Microsoft MDM
    #By.Khaled Elsayed 
    
    write-host " Upgrade Microsoft Teams " -ForegroundColor Green
    write-host " don't close this window, it will be close automatically" -ForegroundColor red
    write-host "_________________________________________________________"
    
    Set-ExecutionPolicy -ExecutionPolicy Bypass -Force
    $ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
        if ($ResolveWingetPath){
               $WingetPath = $ResolveWingetPath[-1].Path
        }
    
    $config
    cd $wingetpath
    cmd.exe /c "winget.exe upgrade microsoft.teams --accept-package-agreements --accept-source-agreements --silent --force"
    exit
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    4 people found this answer helpful.

  2. Pavel yannara Mirochnitchenko 12,786 Reputation points MVP
    2024-05-08T16:46:15.31+00:00

    The issue to get Winget recognized behind system context will be solved with this command:

    Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe

    But the major issue in Winget is, that it does not use winget resource after OS installation or windows enrollment, it will then use only msstore repository. I have MS case opened because of this. I will keep your posted.

    4 people found this answer helpful.

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

  4. Pavel yannara Mirochnitchenko 12,786 Reputation points MVP
    2023-06-15T15:18:49.2766667+00:00

    I am considering an option to include winget.exe with together with every package, next to the PS1 script.

    Actually this behavior varies, some Windows 10 fails as well, and some Windows 11 which uses Windows Terminal already, actually manages to run winget, but that is very rare.


  5. Pavel yannara Mirochnitchenko 12,786 Reputation points MVP
    2023-09-14T11:14:46.7333333+00:00

    I found out that different winget.exe versions behaves differently, some apps are not installed and some are. So including source files together with the app package is a bad solution because eventually they will become obsolete. So, what is the best way to include Winget into fresh installed Windows OS? Because it isn't there yet.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.