您無法在 Web 應用程式中為兩個或多個不同的使用者建立多個 System.Management.Automation Runspace

原始 KB 編號: 3115600

徵狀

當您嘗試允許多個使用者在 Web 應用程式中建立 System.Management.Automation Runspaces,而且您使用隱含認證 (例如來自模擬) 的認證時,您會發現只有第一個存取 Web 應用程式的使用者可以呼叫 方法 CreateRunspace 。 所有後續要求都會失敗,並出現類似以下的例外狀況:

System.Management.Automation.PSInvalidOperationException
at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager.Initialize
在 System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager.。ctor
在 System.Management.Automation.Remoting.ClientRemoteSessionDSHandlerImpl.。ctor
在 System.Management.Automation.Remoting.ClientRemoteSessionImpl.。ctor
在 System.Management.Automation.Internal.ClientRunspacePoolDataStructureHandler.。ctor
在 System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal.CreateDSHandler
在 System.Management.Automation.Runspaces.RunspacePool.。ctor
在 System.Management.Automation.RemoteRunspace.。ctor
在 System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace
在 System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace

原因

產生此錯誤是系統刻意為之。

因應措施

若要在 Web 應用程式中為兩個或多個不同的使用者建立多個 System.Management.Automation Runspace,您必須傳入明確的認證。

其他相關資訊

若要建立多個遠端管理 Runspace,請確定下列條件成立:

  • ASP.NET IIS 虛擬目錄上未啟用模擬。
  • 所有 Windows 模擬邏輯都已從您的程式代碼中移除。
  • 系統會提示您的使用者輸入使用者名稱和密碼。