winget is not recognized as the name of cmdlet

Pavel yannara Mirochnitchenko 13,326 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.
11,859 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.
1,011 questions
{count} votes

7 answers

Sort by: Most helpful
  1. Khaled Elsayed Mohamed 1,335 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.

    6 people found this answer helpful.

  2. Pavel yannara Mirochnitchenko 13,326 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.

    6 people found this answer helpful.

  3. G1415 30 Reputation points
    2025-05-19T08:45:16.27+00:00

    I found the win get upgrade on windows 11 was broken and no matter what I tried it kept coming up with the same error(s) as shown in the picture above.

    I found this simple fix using the code below Just copy and paste the entire code, and it should be problem solved (this is what fixed it for me)winget broken

    $progressPreference = 'silentlyContinue'
    Write-Host "Installing WinGet PowerShell module from PSGallery..."
    Install-PackageProvider -Name NuGet -Force | Out-Null
    Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
    Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
    Repair-WinGetPackageManager
    Write-Host "Done."
    
    
    6 people found this answer helpful.

  4. 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

  5. Pavel yannara Mirochnitchenko 13,326 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.


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.