I am trying to run a simple command on my CM 10.2 instance running on an App Service:
Write-Host "test"
However, the script never seems to run, even if I set a breakpoint and debug. This works fine on other environments. The working environment and the broken environment have the same bin files. The SPE config files also appear to be the same. Nothing has changed as far as I know.
I am an administrator and I have elevated permissions, and I have reproduced the issue with other admin users.
There is nothing notable in the browser console logs on either environment; they are the same.
I can see the POST request to /sitecore/shell/Applications/PowerShell/PowerShellIse?sc_bw=1&xmlcontrol=PowerShellIse
returning a 500 error, with these messages in the logs:
Exception of type 'System.Web.HttpUnhandledException' was thrown. Exception has been thrown by the target of an invocation. The type initializer for 'Spe.Core.Host.ScriptSession' threw an exception. Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Utility because of the following error: Could not load file or assembly 'Microsoft.PowerShell.Commands' or one of its dependencies. The system cannot find the file specified.
System.Web.HttpUnhandledException:
at System.Web.UI.Page.HandleError (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequestMain (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequest (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequest (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequestWithNoAssert (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequest (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at ASP.sitecore_shell_default_aspx.ProcessRequest (App_Web_vqiwhdbc, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStepImpl (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStep (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Inner exception System.Reflection.TargetInvocationException handled at System.Web.UI.Page.HandleError:
at System.RuntimeMethodHandle.InvokeMethod (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Reflection.RuntimeMethodInfo.Invoke (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Processor.Invoke (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Pipeline.Resume (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Pipeline.DoStart (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Pipelines.Pipeline.Start (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Web.UI.Sheer.ClientPage.RunPipelines (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at Sitecore.Web.UI.Sheer.ClientPage.OnPreRender (Sitecore.Kernel, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.UI.Control.PreRenderRecursiveInternal (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.UI.Page.ProcessRequestMain (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Inner exception System.TypeInitializationException handled at System.RuntimeMethodHandle.InvokeMethod:
at Spe.Core.Host.ScriptSession..ctor (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
at Spe.Core.Host.ScriptSessionManager.GetSession (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
at Spe.Client.Applications.PowerShellIse.JobExecuteScript (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
at Spe.Client.Applications.PowerShellIse.JobExecuteSelection (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
Inner exception System.Management.Automation.Runspaces.PSSnapInException handled at Spe.Core.Host.ScriptSession..ctor:
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadConsole (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Management.Automation.PowerShell.get_Runspace (System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Spe.Core.Host.ScriptSession..cctor (Spe, Version=6.3.0.17327, Culture=neutral, PublicKeyToken=null)
The same issue happens even when performing actions in the ISE that shouldn't require elevation, such as pressing the "About" button:
A restart of the App Service did not fix the issue.
I performed a reinstallation of the SPE module, but the issue persists.