Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

MSIX packaged programs can't start in ssh session if already running in another session in some configurations

Open
#2,450 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
powershell

Research direction

Start by running the supplied elevated pwsh reproduction and review the AppModel-Runtime/Admin errors for the session-0 activation path. Compare the sshd/session-0 behavior with the expected container join across sessions. Done means the packaged pwsh/MSIX program launches successfully when an instance is already running in another session.

Written by the indexing model from the issue text.

Description

Area-sshd Investigate
Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Steps to reproduce

Feedback Hub report:

https://aka.ms/AA130s3

Run this script from an elevated pwsh shell installed from winget:

# Repro: packaged app cannot be activated from session 0 while an instance of the
# same package is running in the desktop session.
#
# RUN THIS FROM A pwsh WINDOW (elevated). The pwsh running it is itself the
# packaged app instance that owns the container in session 1, which is the
# condition being demonstrated. No ssh is involved.

$script = "$env:TEMP\appx-session-repro-inner.ps1"
$result = "$env:TEMP\appx-session-repro-result.txt"

@'
$alias = "$env:localappdata\Microsoft\WindowsApps\pwsh.exe"
$error.clear()
$out = & $alias -nologo -noprofile -c '$PSVersionTable.PSVersion.ToString()' 2>&1 | out-string
"session=$([System.Diagnostics.Process]::GetCurrentProcess().SessionId) pwsh_running_in_other_session=$(@(get-process pwsh -ea ignore).Count) out=[$(($out -replace '\s+',' ').Trim())] err=[$(($error[0] -split '\r?\n')[0])]" |
    add-content "$env:TEMP\appx-session-repro-result.txt"
'@ | Set-Content $script

Remove-Item $result -ErrorAction Ignore

$action = New-ScheduledTaskAction `
    -Execute "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `
    -Argument "-noprofile -executionpolicy bypass -file `"$script`""

# -LogonType s4u runs the task as this user in session 0, with no ssh involved.
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType s4u -RunLevel Highest

Register-ScheduledTask -Force -TaskName AppxSessionRepro -Action $action -Principal $principal | Out-Null
Start-ScheduledTask -TaskName AppxSessionRepro
Start-Sleep -Seconds 12
Unregister-ScheduledTask -TaskName AppxSessionRepro -Confirm:$false

'--- result (session 0 activation, packaged pwsh already running on the desktop):'
Get-Content $result

'--- AppModel-Runtime errors logged by the attempt:'
Get-WinEvent -LogName 'Microsoft-Windows-AppModel-Runtime/Admin' -MaxEvents 10 -ErrorAction Ignore |
    Where-Object LevelDisplayName -eq 'Error' | Select-Object -First 3 |
    ForEach-Object { '    ' + ($_.Message -replace '\s+', ' ') }

'--- environment:'
"    build=$([Environment]::OSVersion.Version.Build).$((Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').UBR)"
"    edition=$((Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').EditionID)"
"    package=$((Get-AppxPackage Microsoft.PowerShell).PackageFullName) status=$((Get-AppxPackage Microsoft.PowerShell).Status)"
"    SAC=$((Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy' -ErrorAction Ignore).VerifiedAndReputablePolicyState)"
Expected behavior
Launch MSIX packaged program from Session 0, which is what sshd runs in, joining the container in Session 1 on the desktop.
Actual behavior
Failure to join the container from Session 0 to Session 1 or vice-versa.
Error details
--- result (session 0 activation, packaged pwsh already running on the desktop):
session=0 pwsh_running_in_other_session=1 out=[] err=[Program 'pwsh.exe' failed to run: Access is deniedAt C:\Users\rkito\AppData\Local\Temp\appx-session-repro-inner.ps1:3 char:8]
--- AppModel-Runtime errors logged by the attempt:
    0x80070005: Cannot create the process for package Microsoft.PowerShell_7.6.4.0_x64__8wekyb3d8bbwe because an error was encountered while configuring runtime. [FinishPackageActivation]
    0x80070005: Cannot add process 5716 to Desktop AppX container 92535e51-91ab-11f1-a311-7008948fd66e for package Microsoft.PowerShell_7.6.4.0_x64__8wekyb3d8bbwe because an error was encountered.
    0x80070005: Cannot create the process for package Microsoft.PowerShell_7.6.4.0_x64__8wekyb3d8bbwe because an error was encountered while configuring runtime. [FinishPackageActivation]
--- environment:
    build=26300.9032
    edition=Professional
    package=Microsoft.PowerShell_7.6.4.0_x64__8wekyb3d8bbwe status=Ok
    SAC=2
Environment data
v pwsh{win} ~
rkito@lenovo > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.6.4
PSEdition                      Core
GitCommitId                    7.6.4
OS                             Microsoft Windows 10.0.26300
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Version

10.0.0.0

Visuals

No response

Dominant language
No language data
Stars
8.3k
Forks
820
Avg merge
12m
Merged PRs (30d)
1

Getting set up

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.

More from PowerShell/Win32-OpenSSH

All issues in PowerShell/Win32-OpenSSH

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.