Using winget with pdq deploy?

So i am trying to install an app driectly from the microsoft store. I am able to do it on the machine using winget. I cannot do it through pdq is there a way to make this work?

James D solution is at the bottom wrap the winget in a ps1 file then run it that way.


winget install "lenovo commercial vantage" --accept-package-agreements --accept-source-agreements

is what i put directly into the ps section of pdq deploy and it threw errors. 

If i wrap that ps code into a ps1 file then execute that it worked flawlessly.

Thanks again James D



Date Votes
  • Can you share how you have your package setup and any errors you are getting when it fails through PDQ?

  • winget install "lenovo commercial vantage"

    after that it i hit enter on the remote machine. i tried the same command and it just doesnt work.

  • My guess is it's related to the user PDQ runs the commands as. Either the install is prompting for agreements, so it's not silent and it's asking for interaction. Or the session doesn't have access to Winget. This is just an assumption, it would help to see the errors you're getting and screenshots of the package configuration.

    See if you can integrate --accept-package-agreements and --accept-source-agreements into your script.,source%20license%20agreement%2C%20and%20avoid%20the%20prompt.

  • 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 C:\Windows\AdminArsenal\PDQDeployRunner\service-1\exec\user.ps1:1 char:1
    + winget install "lenovo commercial vantage" --accept-package-agreement ...

    this is the ps output

  • Side Note. If your not, run the PowerShell step calling a PS1 file instead of pasting the script into the PowerShell step itself. This has helped alleviate issues for me, don't understand why it works better though.

    I don't think the PDQ user has access to the Winget app. I'd verifying the app is installed and run the install prior if it's not. Something like this.

    $Winget = Get-AppxPackage -AllUsers "*DesktopAppInstaller*"

    if($Null -eq $Winget)
        Invoke-WebRequest -Uri -OutFile .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
        Invoke-WebRequest -Uri -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
        Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
        Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

  • James D this works. I just wrapped my script in a ps1 file and it worked... Kinda dumb but ive done worse work arounds....

  • I had the same issue to deploy the non commercial version of vantage. You can run single steps as a different users than System or the service account.
    In the "Options" tab of the specific step you are running your script in, select Run As -> Logged in user. 
    My command is literally just:
    winget install "Lenovo Vantage" --source msstore --accept-package-agreements


  • Anyone trying to get winget upgrades to work?

    I'm trying to get "winget upgrade" to work by wrapping it in a .ps1 file with some code that updates winget if it's missing:

    $Winget = Get-AppxPackage -AllUsers "*DesktopAppInstaller*"
    if($Null -eq $Winget)
    $progressPreference = 'Silent'
    $latestWingetMsixBundleUri = $(Invoke-RestMethod | Where-Object {$_.EndsWith(".msixbundle")}
    $latestWingetMsixBundle = $latestWingetMsixBundleUri.Split("/")[-1]
    Write-Information "Downloading winget to artifacts directory..."
    Invoke-WebRequest -Uri $latestWingetMsixBundleUri -OutFile "./$latestWingetMsixBundle"
    Invoke-WebRequest -Uri -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
    Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
    Add-AppxPackage $latestWingetMsixBundle
    winget upgrade --all --accept-package-agreements --accept-source-agreements

    It fails most of the time with this error. Any ideas?

    Failed when searching source: winget
    An unexpected error occurred while executing the command: 
    0x8a15000f : Data required by the source is missing

    I tried resetting the sources, and setting --locale en-us --source winget and that didn't help.
    I have also tried running as Logged on user, but then it can't find winget.

  • WinGet can be ran as System. If you wanted to install VLC for example, using WinGet as System:

    (Credit to Reddit user u/naps1saps)

    $app = 'vlc'; 
    $path = Resolve-Path -Path 'c:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe';
    $args = "install $app --source msstore --scope machine --accept-package-agreements --accept-source-agreements";

    If (Test-Path $path -PathType Leaf) { $p = Start-Process -FilePath $path -WindowStyle Hidden -PassThru -ArgumentList $args; $p.WaitForExit(); }
    else { Write-Output 'Winget path invalid'; }

    I modified it a little to silently install Creative Cloud, as System, using PDQ Connect:

    $path = Resolve-Path -Path 'c:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe';

    $args = "install --id XPDLPKWG9SW2WD --silent --source msstore --scope machine --accept-package-agreements --accept-source-agreements";

    If (Test-Path $path -PathType Leaf) {
        $p = Start-Process -FilePath $path -WindowStyle Hidden -PassThru -ArgumentList $args;
    } else {
        Write-Output 'Winget path invalid';

Please sign in to leave a comment.

Didn't find what you were looking for?

New post