Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ static PowerShellProcessInstance()
PwshExePath = Path.Combine(Utils.DefaultPowerShellAppBase, "pwsh");
#else
PwshExePath = Path.Combine(Utils.DefaultPowerShellAppBase, "pwsh.exe");
WinPwshExePath = Path.Combine(Utils.GetApplicationBaseFromRegistry(Utils.DefaultPowerShellShellID), "powershell.exe");
var winPowerShellDir = Utils.GetApplicationBaseFromRegistry(Utils.DefaultPowerShellShellID);
WinPwshExePath = string.IsNullOrEmpty(winPowerShellDir) ? null : Path.Combine(winPowerShellDir, "powershell.exe");
#endif
}

Expand All @@ -59,6 +60,11 @@ public PowerShellProcessInstance(Version powerShellVersion, PSCredential credent
startingWindowsPowerShell51 = (powerShellVersion != null) && (powerShellVersion.Major == 5) && (powerShellVersion.Minor == 1);
if (startingWindowsPowerShell51)
{
if (WinPwshExePath == null)
{
throw new PSInvalidOperationException(RemotingErrorIdStrings.WindowsPowerShellNotPresent);
}

exePath = WinPwshExePath;

if (useWow64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1693,4 +1693,7 @@ All WinRM sessions connected to PowerShell session configurations, such as Micro
<data name="RemoteDebuggerError" xml:space="preserve">
<value>Remote debugger exception: {0}, error message: {1}</value>
</data>
<data name="WindowsPowerShellNotPresent" xml:space="preserve">
<value>Unable to create Windows PowerShell process because Windows PowerShell could not be found on this machine.</value>
</data>
</root>