首页 > 解决方案 > ADInvalidCredentialException 与 Exchange 2010 的 PowerShell 远程管理

问题描述

(我的英语不好)嗨,技术人员,

我正在尝试使用以管理员身份执行 cmd 的远程 PowerShell 获取邮箱统计信息。

powershell -command "$session=New-PSSession -ComputerName 'EX2' -Credential $cred; invoke-command -Session $session -ScriptBlock { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; dir env:}"

这个命令没问题

命令输出

但我将命令更改为Get-MailboxDatabase

powershell -command "$session=New-PSSession -ComputerName 'EX2' -Credential $cred; invoke-command -Session $session -ScriptBlock { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; Get-MailboxDatabase -Status}"

我得到一个ADInvalidCredentialException

错误输出

标签: powershellexchange-serverpowershell-remotingexchange-server-2010invoke-command

解决方案


您必须按如下方式连接到 Exchange Server:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<ServerFQDN>/PowerShell/ -Authentication Kerberos -Credential $UserCredential

请参阅Microsoft 文档文章

然后要么:

一个)

Import-PSSession $Session -DisableNameChecking
Get-Mailbox

b)

Invoke-Command -Session $Session -ScriptBlock { Get-Mailbox }

推荐阅读