PowerShell/PowerShell · critical · ConsoleHostStartupException
The shell cannot be started. A failure occurred during initi
Error message
The shell cannot be started. A failure occurred during initialization:
What it means
During startup, ConsoleHost loads the session configuration from the -ConfigurationFile path via InitialSessionState.CreateFromSessionConfigurationFile (with validateFile:true). Any exception thrown by that load is wrapped in ConsoleHostStartupException 'ShellCannotBeStarted', so the message alone is generic — the real cause is in the InnerException.
Source
Thrown at src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:1722
Dbg.Assert(_runspaceRef == null, "_runspaceRef field should be null");
Dbg.Assert(DefaultInitialSessionState != null, "DefaultInitialSessionState should not be null");
s_runspaceInitTracer.WriteLine("Calling RunspaceFactory.CreateRunspace");
// Use session configuration file if provided.
bool customConfigurationProvided = false;
if (!string.IsNullOrEmpty(args.ConfigurationFilePath))
{
try
{
// Replace DefaultInitialSessionState with the initial state configuration defined by the file.
DefaultInitialSessionState = InitialSessionState.CreateFromSessionConfigurationFile(
path: args.ConfigurationFilePath,
roleVerifier: null,
validateFile: true);
}
catch (Exception ex)
{
throw new ConsoleHostStartupException(ConsoleHostStrings.ShellCannotBeStarted, ex);
}
customConfigurationProvided = true;
}
try
{
Runspace consoleRunspace = null;
bool psReadlineFailed = false;
// Load PSReadline by default unless there is no use:
// - we're running a command/file and just exiting
// - stdin is redirected by a parent process
// - we're not interactive
// - we're explicitly reading from stdin (the '-' argument)
// It's also important to have a scenario where PSReadline is not loaded so it can be updated, e.g.
// powershell -command "Update-Module PSReadline"
// This should work just fine as long as no other instances of PowerShell are running.View on GitHub (pinned to 3ff3c711bf)
Solutions
- Inspect InnerException of the thrown ConsoleHostStartupException to get the precise cause (file not found, schema error, etc.).
- Validate the .pssc path exists and is readable before launch.
- Re-generate or re-sign the .pssc with a current PowerShell; run Test-PSSessionConfigurationFile on it.
- Fix file permissions so the host account can read the config.
Example fix
// diagnose
try { /* start host with -ConfigurationFile */ }
catch (ConsoleHostStartupException ex) { Log(ex.InnerException); } // real reason
// then repair the .pssc or correct the path Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(args.ConfigurationFilePath)) throw new FileNotFoundException(args.ConfigurationFilePath); // optionally pre-validate the .pssc schema/signature before launch
Type guard
// not applicable
Try / catch
try { /* start with -ConfigurationFile */ }
catch (ConsoleHostStartupException ex)
{ var cause = ex.InnerException ?? ex; /* inspect cause, fix file */ } Prevention
- Run Test-PSSessionConfigurationFile on the .pssc before launch.
- Keep .pssc files version-aligned with the PowerShell build.
- Verify read permissions for the host account.
When it happens
Trigger: Passing -ConfigurationFile pointing at a .pssc file that is missing, unreadable, malformed, fails schema/signature validation, or is rejected by the role verifier.
Common situations: Typo in the config path; corrupt or hand-edited .pssc; file written by an incompatible PowerShell version; permission denied reading the file; signing/validation failure on a locked-down system.
Related errors
- The shell cannot be started. An InitialSessionState object h
- This instance has already been used. Create a new instance.
- PushRunspace can only push a remote runspace.
- Node is not present in the XML, Please give valid XPath
- Unable to find DSC schema store at {dscConfigurationDirector
AI-assisted analysis of PowerShell/PowerShell@3ff3c711bf (2026-08-13).
Data as JSON: /api/errors/9932ba6f80bfb459.
Report an issue: GitHub.