winget is not recognized as the name of cmdlet

Pavel yannara Mirochnitchenko 10,776 Reputation points
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.
6,747 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.
799 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Khaled El-Sayed Mohamed 985 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.

    1 person found this answer helpful.
    0 comments No comments

  2. Limitless Technology 43,231 Reputation points
    2023-06-15T10:37:00.1533333+00:00

    Hello Pavel,

    Thank you for your question and for reaching out with your question today.

    If you're encountering the error "winget is not recognized as the name of cmdlet" even when running as an administrator, it suggests that the winget command-line tool is not installed or not properly configured on the Windows 11 computer. Here are a few steps you can take to address this issue:

    1. Verify Windows 11 version: Ensure that the Windows 11 version installed on the computer supports the winget tool. It's recommended to have Windows 11 build 22000 or later for full support of the winget command-line tool.
    2. Install the Windows Package Manager: Confirm that the Windows Package Manager (winget) is installed on the computer. You can download and install the Windows Package Manager manually from the Microsoft winget GitHub repository. Make sure to choose the appropriate installer package for your system architecture.
    3. Check system PATH variable: Verify that the location where winget is installed is added to the system's PATH environment variable. By default, winget is installed in the "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_8.1.19411.0_x64__8wekyb3d8bbwe" directory. Ensure that this directory is included in the PATH variable.
    4. Restart the computer: After installing winget and ensuring the PATH variable is properly configured, it's recommended to restart the computer to ensure all changes take effect.

    Once you have performed these steps, try running the winget command again as an administrator, and it should now be recognized as a valid cmdlet.

    If the issue persists, it might be worth considering reinstalling Windows Package Manager.

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    If the reply was helpful, please don’t forget to upvote or accept as answer.

    Best regards.

    0 comments No comments

  3. Pavel yannara Mirochnitchenko 10,776 Reputation points
    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.


  4. Pavel yannara Mirochnitchenko 10,776 Reputation points
    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.


  5. Tim 0 Reputation points
    2023-12-01T08:48:13.7666667+00:00

    I just got this error - turns out the winget version was upgraded.

    Moved from
    c:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.21.2771.0_x64__8wekyb3d8bbwe
    to
    c:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.21.3133.0_x64__8wekyb3d8bbwe

    0 comments No comments