我正在尝试建立PowerShell会话以在localhost上的Exchange服务器上运行多个Exchange命令。这不是一个常量问题,脚本有时会成功运行,但大多数时候它会抛出以下错误:
New-PSSession : [Exchange-server-name] Connecting to remote server Exchange-server-name failed with the following error message : Access is denied. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:9 char:15
+ $newsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ...
+
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null argument and try the command again.
At line:10 char:27
+ import-PSSession -session $newsession -AllowClobber
以下是我的PSSession命令:
$newsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://Exchange-server-name/PowerShell/ -Authentication Kerberos -Credential $Credential