使用PSSession和Microsoft.Exchange.Management.PowerShell.SnapIn时出错

使用PSSession和Microsoft.Exchange.Management.PowerShell.SnapIn时出错,powershell,exchange-server,exchange-management-shell,Powershell,Exchange Server,Exchange Management Shell,因此,尝试使用PSSession在本地运行Exchange命令行管理程序,但AD操作失败 这是我的步骤 1) 以管理员身份打开PSmodule (二) (三) (四) 这就是我得到错误的地方。-> Active Directory operation failed on . The supplied credential for 'domain\user' is invalid. + CategoryInfo : NotSpecified: (:) [], ADInvalidC

因此,尝试使用PSSession在本地运行Exchange命令行管理程序,但AD操作失败

这是我的步骤

1) 以管理员身份打开PSmodule

(二)

(三)

(四)

这就是我得到错误的地方。->

Active Directory operation failed on . The supplied credential for 'domain\user' is invalid.
+ CategoryInfo          : NotSpecified: (:) [], ADInvalidCredentialException
+ FullyQualifiedErrorId : [Server=CHGDAG01,RequestId=4f848ef8-264c-4db7-a4e8-2acf2dae560f,TimeStamp=5/13/2016 4:45
:55 PM][FailureCategory=Cmdlet ADInvalidCredentialException]5533B753


奇怪的是,如果我将具有相同凭据的RDP放入DAG并运行ExchangeManagementShell,一切都会正常工作

您需要将
pscredential
对象传递给
-Credential
参数

您可以使用
$cred=Get Credential
然后
-Credential$cred


这可用于从远程exchange服务器导入PSSession

$Params = @{
    ConfigurationName = 'Microsoft.Exchange'
    ConnectionUri = "http://youexchangeserver.server.com/PowerShell/"
    Credential = ( Get-Credential )
    Authentication = 'Kerberos'
    Name = 'ExchangeSession'
}
Import-PSSession -Session ( New-PSSession @Params )
但是,我不了解您的工作原理,因此我会尝试以下方法:

$Credential = Get-Credential
Enter-PSSession -ComputerName DAG01 -Credential $Credential
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

我将注意到,如果您以执行操作的帐户身份运行PowerShell,则甚至不需要指定凭据。

$creds=Get Credential

$sess=新PSSession-ConfigurationName Microsoft.Exchange-ConnectionUri-AuthenticationKerberos-Credential$creds

然后严格地与用户交换命令 输入PSSession$sess

获取邮箱xyz

出口

或者做一些PowerShell+交换的东西 导入PSSession$sess

获取邮箱xyz

\dosomshing.PS1

删除PSSession$sess


这是来自

的信息,听起来正确,但不起作用。看:第一部分有效,但第二部分无效。它应该但不应该。
$User=“Domain01\User01”$PWord=转换为SecureString-字符串“P@sSwOrd“-AsPlainText-武力$Credential=新对象-TypeName System.Management.Automation.PSCredential-ArgumentList$User,$PWord
Active Directory operation failed on . The supplied credential for 'domain\user' is invalid.
+ CategoryInfo          : NotSpecified: (:) [], ADInvalidCredentialException
+ FullyQualifiedErrorId : [Server=CHGDAG01,RequestId=4f848ef8-264c-4db7-a4e8-2acf2dae560f,TimeStamp=5/13/2016 4:45
$Params = @{
    ConfigurationName = 'Microsoft.Exchange'
    ConnectionUri = "http://youexchangeserver.server.com/PowerShell/"
    Credential = ( Get-Credential )
    Authentication = 'Kerberos'
    Name = 'ExchangeSession'
}
Import-PSSession -Session ( New-PSSession @Params )
$Credential = Get-Credential
Enter-PSSession -ComputerName DAG01 -Credential $Credential
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn