Stuck PowerShell processes on the MID server host


Description

More than one PowerShell version installed on the mid server host can cause the PowerShell processes to be stuck on the host. Eventually, the mid server will be restarting and the host storage space will be filled with heap dumps.

Possibly, you could see the following errors in the logs:

---------------------------------------------

All seems to be related to a PowerShellInitialization error 'Error encountered when invoking PowerShell, the result from running '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -noninteractive -nologo -noprofile -command "$ver = if (Test-Path Variable:\PSVersionTable) { $PSVersionTable.PSVersion } else { (get-host).Version }; 'full_version:' + $ver.ToString() + ', major_version:' + $ver.Major"' is'

---------------------------------------------


Release or Environment

All

Cause

1. Multiple PowerShell versions are installed and active on the Windows host

2. Incorrect path is specified in the parameter "mid.powershell.path"

Resolution

1. For "Multiple PowerShell versions are installed and active on the Windows host" issue:

- Run the cmd: DISM /online /get-features /format:table | more
DISM /online /get-features /format:table | find “Enabled” | more


- Find out the enabled PS versions

- Disable the unwanted versions using cmd: DISM /online /disable-feature /featurename:[paste the feature name here]



2. For "Incorrect path is specified in the parameter "mid.powershell.path"" issue:

- Run the PS command:

$PSVersionTable
$env:path -split ";"

- Note down the path of the PowerShell

- Specify that path in the mid sever parameter "mid.powershell.path"


Finally restart the mid server host.

Additional Information

Quick relief is to Restart the mid server host.