【发布时间】:2019-05-22 11:45:27
【问题描述】:
我有一台交换服务器和一台 Windows 7 机器。
W.R.T 远程执行
服务器 - Exchange 服务器(Win server 2012) 客户端 - Win 7 机器
我想在远程机器(exchange/win server 2012)上运行客户端机器中存在的脚本。但是这些都失败了,找不到错误 cmdlet。
所以为了快速检查,我尝试调用普通的 powershell cmdlet 以及交换 cmdlet,发现只有交换 cmdlet 失败。但是,如果我在服务器(交换)上运行相同的 cmdlet,它会给我预期的输出。
问题
- Exchange cmdlet 不能在远程 powershell 中工作吗?
- 我尝试了使用交换服务器作为连接 URL 的不同会话类型,但在那里也遇到了错误。
附在下面的示例测试输出。
帮助我如何进一步进行!
在远程客户端(Win 7 机器)
PS C:\Users\Administrator> invoke-command -Session $session -ScriptBlock { ls }
返回:
Directory: C:\Users\Administrator\Documents
Mode LastWriteTime Length Name PSComputerName
---- ------------- ------ ---- --------------
d----- 12/2/2018 12:10 PM WindowsPowerShell 10.76.68.251
但 Exchange cmdlet 不起作用
PS C:\Users\Administrator> invoke-command -Session $session -ScriptBlock { Get-Mailbox }
The term 'Get-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (Get-Mailbox:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : 10.76.68.251
服务器 - Exchange / Server 2012
PS C:\Users\Administrator\Downloads\custom scripts> Get-Mailbox
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- -----------------
Administrator Administrator win-j1uti0rc7qp Unlimited
DiscoverySearchMailbox... DiscoverySearchMa... win-j1uti0rc7qp 50 GB (53,687,091,200 bytes)
使用连接 URI 中的 Exchange Server URL 进行测试
测试 1
PS C:\Users\Administrator> $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://10.76.68.251/PowerShell/ -Authentication Kerberos -Credential $credential
错误:
New-PSSession : [10.76.68.251] Connecting to remote server 10.76.68.251 failed with the following error message : The WinRM client cannot process the request. Kerberos authentication cannot be used when the destination is an IP address. Specify a DNS or NetBIOS destination or specify Basic or Negotiate authentication. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:13 + $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri h ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : -2144108277,PSSessionOpenFailed
测试 2
PS C:\Users\Administrator> $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://10.76.68.251/PowerShell/ -Credential $credential
错误:
New-PSSession : [10.76.68.251] Connecting to remote server 10.76.68.251 failed with the following error message : The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:13 + $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri h ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession],PSRemotingTransportException + FullyQualifiedErrorId : -2144108297,PSSessionOpenFailed
【问题讨论】:
标签: powershell exchange-server exchangewebservices powershell-remoting