Skip to content

Enter-PsSession: NullReferenceException crash in 7.4.1 #21253

@scalessm

Description

@scalessm

Prerequisites

Steps to reproduce

  1. Open a powershell
  2. Use Get-Credential to capture a credential that has permissions to remote into a different machine
  3. Type: Enter-PsSession [remote machine] -Credentials [credentials]

Note
This only seems to occur during an interactive session. If I use Invoke-Command passing a computer name, or session variable, it executes without issue. e.g. The following works:

$creds = Get-Credential
$script = { Get-ChildItem }
Invoke-Command [Computer] -ScriptBlock $script -Credential $creds

Expected behavior

An interactive remote session is started

Actual behavior

The terminal displays a NullReferenceException then crashes

Error details

Application: pwsh.exe
CoreCLR Version: 8.0.123.58001
.NET Version: 8.0.1
Description: The application requested process termination through System.Environment.FailFast.
Message: Object reference not set to an instance of an object.
Description: The process was terminated due to an unhandled exception.System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Management.Automation.Security.SystemPolicy.LogWDACAuditMessage(ExecutionContext context, String title, String message, String fqid, Boolean dropIntoDebugger)
   at System.Management.Automation.Remoting.RunspaceRef.ParsePsCommandUsingScriptBlock(String line, Nullable`1 useLocalScope)
   at System.Management.Automation.Remoting.RunspaceRef.CreatePipeline(String line, Boolean addToHistory, Boolean useNestedPipelines)
   at Microsoft.PowerShell.Executor.ExecuteCommandAndGetResultAsString(String command, Exception& exceptionThrown)
   at Microsoft.PowerShell.ConsoleHost.InputLoop.EvaluatePrompt()
   at Microsoft.PowerShell.ConsoleHost.InputLoop.Run(Boolean inputLoopIsNested)
   at Microsoft.PowerShell.ConsoleHost.InputLoop.RunNewInputLoop(ConsoleHost parent, Boolean isNested)
   at Microsoft.PowerShell.ConsoleHost.EnterNestedPrompt()
   at Microsoft.PowerShell.ConsoleHost.DoRunspaceLoop(String initialCommand, Boolean skipProfiles, Collection`1 initialCommandArgs, Boolean staMode, String configurationName, String configurationFilePath)
   at Microsoft.PowerShell.ConsoleHost.Run(CommandLineParameterParser cpp, Boolean isPrestartWarned)
   at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText, Boolean issProvidedExternally)
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
Stack:
   at System.Environment.FailFast(System.String, System.Exception)
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
   at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])

Environment data

Name                           Value

----                           -----

PSVersion                      7.4.1

PSEdition                      Core

GitCommitId                    7.4.1

OS                             Microsoft Windows 10.0.19045

Platform                       Win32NT

PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}

PSRemotingProtocolVersion      2.3

SerializationVersion           1.1.0.1

WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    7.4-regressionRegression in 7.4In-PRIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productWG-RemotingPSRP issues with any transport layer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions