有时候通过Invoke-Command远程到Exchange上执行命令或脚本报错,可以通过另一种方式实现远程管理

#导入Exchange模块
$RemoteServerMail = "mail04.xx.com"
$SessionMail = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$RemoteServerMail/PowerShell/ -Credential $Cred_Mail -AllowRedirection
# Import-PSSession $SessionMail -AllowClobber
Import-PSSession $SessionMail -AllowClobber

#直接运行Ex命令即可
Get-Mailbox