Crash with direct launch of PowerShell 7 #20806

Closed
opened 2026-01-31 07:24:33 +00:00 by claunia · 4 comments
Owner

Originally created by @emirefek on GitHub (Nov 13, 2023).

Windows Terminal version

1.18.2822.0

Windows build number

Win32NT 10.0.22631.0

Other Software

No response

Steps to reproduce

When I run "PowerShell 7" directly it works under "Windows Terminal". But when I run "Windows Terminal" directly it gives a error while trying to open "PowerShell 7"

Expected Behavior

PowerShell 7.3.9
PS C:\Users\user>

Actual Behavior

Process terminated. The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
System.TypeInitializationException: The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.
---> System.ComponentModel.Win32Exception (126): Specified module not found.
at System.Management.Automation.Internal.SecuritySupport.GetSaferPolicy(String path, SafeHandle handle)
at System.Management.Automation.Security.SystemPolicy.TestSaferPolicy(String testPathScript, String testPathModule)
at System.Management.Automation.Security.SystemPolicy.GetAppLockerPolicy(String path, SafeHandle handle)
at System.Management.Automation.Security.SystemPolicy.GetLockdownPolicy(String path, SafeHandle handle)
at System.Management.Automation.Security.SystemPolicy.GetSystemLockdownPolicy()
at System.Management.Automation.Runspaces.InitialSessionState..cctor()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
[process exited with code 2148734499 (0x80131623)]
You can now close this terminal with Ctrl+D, or press Enter to restart.

https://github.com/PowerShell/PowerShell/issues/20595

Originally created by @emirefek on GitHub (Nov 13, 2023). ### Windows Terminal version 1.18.2822.0 ### Windows build number Win32NT 10.0.22631.0 ### Other Software _No response_ ### Steps to reproduce When I run "PowerShell 7" directly it works under "Windows Terminal". But when I run "Windows Terminal" directly it gives a error while trying to open "PowerShell 7" ### Expected Behavior PowerShell 7.3.9 PS C:\Users\user> ### Actual Behavior Process terminated. The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception. at System.Environment.FailFast(System.String, System.Exception) at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32) at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[]) System.TypeInitializationException: The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception. ---> System.ComponentModel.Win32Exception (126): Specified module not found. at System.Management.Automation.Internal.SecuritySupport.GetSaferPolicy(String path, SafeHandle handle) at System.Management.Automation.Security.SystemPolicy.TestSaferPolicy(String testPathScript, String testPathModule) at System.Management.Automation.Security.SystemPolicy.GetAppLockerPolicy(String path, SafeHandle handle) at System.Management.Automation.Security.SystemPolicy.GetLockdownPolicy(String path, SafeHandle handle) at System.Management.Automation.Security.SystemPolicy.GetSystemLockdownPolicy() at System.Management.Automation.Runspaces.InitialSessionState..cctor() --- End of inner exception stack trace --- at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2() at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc) [process exited with code 2148734499 (0x80131623)] You can now close this terminal with Ctrl+D, or press Enter to restart. https://github.com/PowerShell/PowerShell/issues/20595
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 07:24:34 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 13, 2023):

based on the linked thread, I'm gonna say this is /dup #16051

There was a bug in Terminal's env var generation, which only manifests when there's a embedded NUL in one of the env vars: https://github.com/microsoft/terminal/issues/16051#issuecomment-1764546234

We should be hotfixing that sometime this week

@zadjii-msft commented on GitHub (Nov 13, 2023): based on the linked thread, I'm gonna say this is /dup #16051 There was a bug in Terminal's env var generation, which only manifests when there's a embedded NUL in one of the env vars: https://github.com/microsoft/terminal/issues/16051#issuecomment-1764546234 We should be hotfixing that sometime this week
Author
Owner

@ninbura commented on GitHub (Feb 4, 2024):

I have started receiving this error today after updating windows Terminal to 1.19.10292.0.

I'm executing the following command via an Elgato Stream Deck

wt pwsh -ExecutionPolicy bypass -WindowStyle normal -file "C:\repos\ff-screenshot\screenshot.ps1" -outputDirectory "\\192.168.2.5\a-sexy-renderer\drive\My files\pictures\ff-screenshot" -saveToDirectory y -copyToClipboard y -captureDevice "Video (00-1 Pro Capture Dual HDMI 4K+)" -bypassQuit y

The Get-EnvsWithEmbeddedNull.ps1 PowerShell script linked in https://github.com/microsoft/terminal/issues/16051 prints nothing for me. Uninstalling and re-installing Windows Terminal via Winget in PowerShell ISE did not fix the issue.

This script/command has never given me issues until now... I'm completely lost, with seemingly no method of fixing this issue.

@ninbura commented on GitHub (Feb 4, 2024): I have started receiving this error today after updating windows Terminal to `1.19.10292.0`. I'm executing the following command via an Elgato Stream Deck ``` wt pwsh -ExecutionPolicy bypass -WindowStyle normal -file "C:\repos\ff-screenshot\screenshot.ps1" -outputDirectory "\\192.168.2.5\a-sexy-renderer\drive\My files\pictures\ff-screenshot" -saveToDirectory y -copyToClipboard y -captureDevice "Video (00-1 Pro Capture Dual HDMI 4K+)" -bypassQuit y ``` The `Get-EnvsWithEmbeddedNull.ps1` PowerShell script linked in https://github.com/microsoft/terminal/issues/16051 prints nothing for me. Uninstalling and re-installing Windows Terminal via Winget in PowerShell ISE did not fix the issue. This script/command has never given me issues until now... I'm completely lost, with seemingly no method of fixing this issue.
Author
Owner

@DHowett commented on GitHub (Feb 5, 2024):

This was fixed in 1.19.10302.0. It should be available in the store as of Jan 30, 2024.

@DHowett commented on GitHub (Feb 5, 2024): This was fixed in 1.19.10302.0. It should be available in the store as of Jan 30, 2024.
Author
Owner

@ninbura commented on GitHub (Feb 6, 2024):

Good to hear there's a fix, unfortunately I am unable to pull said update via winget or Microsoft Store even now.

I may just have to pull the zip from the repo and use PowerShell to move the files to WindowsApps.

Edit - jk there's a msixbundle option on the repo.

@ninbura commented on GitHub (Feb 6, 2024): Good to hear there's a fix, unfortunately I am unable to pull said update via winget or Microsoft Store even now. I may just have to pull the zip from the repo and use PowerShell to move the files to WindowsApps. Edit - jk there's a [msixbundle](https://github.com/microsoft/terminal/releases/download/v1.19.10302.0/Microsoft.WindowsTerminal_1.19.10302.0_8wekyb3d8bbwe.msixbundle) option on the repo.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20806