【发布时间】:2014-11-04 18:00:02
【问题描述】:
无论如何,我正在编写一些用于工作的 Powershell 脚本,但我坚持做一些我认为相当简单的事情。基本上,我需要在我们的 Exchange 服务器上执行一些非常适合编写脚本的任务。我花时间编写了一个脚本,它将我连接到我们的服务器(在同一个域上),并为一些测试命令运行 invoke-command。一旦我运行了测试命令,我就可以真正开始编写脚本了。
然而,现在,我只是让 get-mailbox 返回任何信息,这实际上只是我试图测试事情是否正常。看这里的三行测试代码:
$mainSession = New-PSSession -ComputerName TheServerName
invoke-command -session $mainSession -ScriptBlock {add-pssnapin Microsoft.Exchange.Management.Powershell.Admin}
invoke-command -session $mainSession -ScriptBlock {get-mailbox}
我收到带有“Job_Failure”错误的“psremotingtransportexception”异常。这可能是什么?我知道管理单元和get-mailbox 命令在我实际通过远程桌面登录到服务器并对其进行测试时起作用。假设我可以让get-mailbox 运行,我实际上可以执行我想放入脚本中的更复杂的任务。我要连接的 Exchange Server 已经很老了(2007 年?),所以并不是我使用了错误的管理单元。我是否缺少一些凭据?现在它没有要求我提供任何东西,但我尝试添加 -credential 标志,但这也没有帮助。
我是 Powershell 的超级新手,因此非常感谢任何帮助。这是确切的错误,为废话格式道歉:
Processing data for a remote command failed with the following error message: The WSMan provider host process did not return a proper response. A provider in the host process may have behaved improperly. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OperationStopped: (System.Manageme...pressionSyncJob:PSInvokeExpressionSyncJob) [], PSRemotingTransportException + FullyQualifiedErrorId : JobFailure
我应该提到我已经尝试通过set-item wsman:\localhost\shell\MaxMemoryPerShellMB 1024 -force 增加外壳 MB 大小。我最好的猜测是这与-credential 标志有关,但到目前为止我还没有成功。
【问题讨论】:
标签: powershell exchange-server powershell-3.0 powershell-remoting exchange-server-2007