microsoft / microsoft/winget-cli

Non-interactive winget download does not work - Error: 0x80070520 : A specified logon session does not exist.

Open
#5,398 7 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Command-Download Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

We need to download non-interactively every week a bunch of applications from the store. Therefore we use an automated runner pc. A CI/CD pipeline is calling a powershell script remotely on this runner PC which is essentially downloading all apps in our repository for the latest versions. Then we can check which one need an update (as the store backend still does not deliver consistently the current versions). But even when we could see the version we still need the ability to automatically download it without user intervention.

When using the interactive logon the download works like a charm. Using the exact same download command via invoke-command it fails.

Steps to reproduce

Working on TESTCOMPUTER:
Logon with a valid EntraID account to a recent Win11 computer:
winget download --id 9WZDNCRFJBH4 --download-directory C:\windows\temp\downloadtest --accept-package-agreements --accept-source-agreements --skip-license --source msstore --verbose

Not working from RemoteComputer accessing remotely the TESTCOMPUTER:
Logon with the same account on a remote computer (powershell remoteing need to be enabled! So Invoke-Command is working in general)
This computer is used to do the remote access to the first computer where you originally were able to do the download!
From remote computer execute first this to see if remoting works as expected:

  1. invoke-command -ComputerName TESTCOMPUTER -ScriptBlock {get-childitem -Path C:\Users}
    This must show the content for C:\Users and valdiates that remoting is correctly configured!

  2. invoke-command -ComputerName TESTCOMPUTER -ScriptBlock {winget download --id 9WZDNCRFJBH4 --download-directory C:\windows\temp\downloadtest --accept-package-agreements --accept-source-agreements --skip-license --source msstore --verbose}

This will fail:
An unexpected error occurred while executing the command:
0x80070520 : A specified logon session does not exist. It may already have been terminated.

Works - Local Interactive WinGet-2025-04-21-10-44-23.567.log

Does not work - Remote NonInteractive WinGet-2025-04-21-10-41-48.861.log

Expected behavior

Non-interactive logon remotely when executed by some automation works the same as when someone is using interactively winget.
For automation its essentially to find a solution that allows this to carry out fully automatically without the need for human interaction.
Best to be executed within a CI/CD pipeline running in Gitlab or Github.

In our case its still enough to have the download non-interactively. There is no need for installation in this user context.
Our packaging solution will then pickup the updated files and generate automatically SCCM packages from it.

As we need to mimik the SCCM store integration feature which was just cut off last year.

Actual behavior

Currently not possible to download the files non interactively.

It fails with this full error message:
Microsoft Store package download requires Microsoft Entra Id authentication. Authentication prompt may appear when necessary. Authenticated information will be shared with Microsoft services for access authorization. For Microsoft Store package licensing,
the Microsoft Entra Id account needs to be a member of Global Administrator, User Administrator, or License Administrator.
Multiple Microsoft Store packages may be downloaded targeting different platforms and architectures. --platform, --architecture can be used to filter the packages.
An unexpected error occurred while executing the command:
0x80070520 : A specified logon session does not exist. It may already have been terminated.

Environment
Windows Package Manager v1.10.340
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19045.5737
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.25.340.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
Installer Downloads                %USERPROFILE%\Downloads
Configuration Modules              %LOCALAPPDATA%\Microsoft\WinGet\Configuration\Modules

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
ProxyCommandLineOptions                   Disabled
DefaultProxy                              Disabled

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the local interactive and remote Invoke-Command downloads on Windows, then compare the two attached logs. Trace the authentication path used by the Microsoft Store source for winget download. Done means the documented non-interactive remote command downloads the requested package without human interaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
authentication, cli
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.