Asp.net 获得;由于对象的当前状态,操作无效;Exchange命令出错
我有一个ASP.NET 3.5应用程序运行Powershell脚本来添加/更新Exchange邮箱。大多数Powershell命令都工作得很好,但到目前为止有两个命令导致了错误:get calendarprocessing和set calendarprocessing,这两个命令获取或设置分配给安排房间的用户。错误为System.Management.Automation.CmdleInvocationException:由于对象的当前状态,操作无效。当我从Exchange命令行管理程序运行命令时,它们工作正常。我们已修补并重新启动Exchange服务器 命令示例: 获取calendarprocessing Room.1 |选择-展开bookinpolicy(或类似变体)Asp.net 获得;由于对象的当前状态,操作无效;Exchange命令出错,asp.net,powershell,exchange-server,cmdlets,Asp.net,Powershell,Exchange Server,Cmdlets,我有一个ASP.NET 3.5应用程序运行Powershell脚本来添加/更新Exchange邮箱。大多数Powershell命令都工作得很好,但到目前为止有两个命令导致了错误:get calendarprocessing和set calendarprocessing,这两个命令获取或设置分配给安排房间的用户。错误为System.Management.Automation.CmdleInvocationException:由于对象的当前状态,操作无效。当我从Exchange命令行管理程序运行命令
看看这是否有帮助:不,不幸的是没有帮助。这发生在web服务中,但我确实在测试web应用程序中添加了这些web.config设置,以防万一。更新:我让某人在服务器上重新安装了Exchange,然后它就工作了。
Private Function RunScript(ByVal ScriptFileName As String, ByVal Arguments() As String) As Collection(Of PSObject)
Dim sb As New StringBuilder
Dim strScript As String
' create Powershell runspace and open
If psRunspace Is Nothing Then
psRunspace = InitializeRunspace()
End If
'Grab Powershell script from text (.ps1) file
strScript = File.ReadAllText(ScriptFileName)
'inject the arguments into the script
strScript = InsertArguments(strScript, Arguments)
Logging.LogMessage(strScript)
'Open the runspace and create a pipeline if it's not already open
If psRunspace.RunspaceStateInfo.State = RunspaceState.BeforeOpen Then
psRunspace.Open()
End If
Dim MyPipeline As Pipeline = psRunspace.CreatePipeline()
MyPipeline.Commands.AddScript(strScript)
Try
Dim psResults As Collection(Of PSObject)
psResults = MyPipeline.Invoke() 'ERRORS HERE
Return psResults
Catch ex As Exception
Logging.LogMessage(ex.Message)
Throw ex
End Try
End Function