[英]Error when using PSSession and Microsoft.Exchange.Management.PowerShell.SnapIn
So trying to run Exchange Management Shell Locally using PSSession, but getting an AD Operation Failure.因此尝试使用 PSSession 在本地运行 Exchange Management Shell,但出现 AD 操作失败。
Here are my steps这是我的步骤
1)open PSmodule as Admin 1)以管理员身份打开PSmodule
2) 2)
Enter-PSSession -ComputerName DAG01 -Credential domain\user
3) 3)
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
4) 4)
Search-Mailbox user -SearchQuery Subject:"anything" -EstimateResultOnly
This is where i get the error.这是我得到错误的地方。 -> ->
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 :55 PM] [FailureCategory=Cmdlet-ADInvalidCredentialException] 5533B753
Weird thing is that if I RDP with the same credentials into the DAG and run Exchange Management Shell, everything works fine.奇怪的是,如果我使用相同的凭据通过 RDP 进入 DAG 并运行 Exchange Management Shell,一切正常。
You need to pass a pscredential
object to the -Credential
parameter.您需要将pscredential
对象传递给-Credential
参数。
You can use $cred = Get-Credential
then -Credential $cred
您可以使用$cred = Get-Credential
然后-Credential $cred
This can be used to import a PSSession from your remote exchange server.这可用于从远程交换服务器导入 PSSession。
$Params = @{
ConfigurationName = 'Microsoft.Exchange'
ConnectionUri = "http://youexchangeserver.server.com/PowerShell/"
Credential = ( Get-Credential )
Authentication = 'Kerberos'
Name = 'ExchangeSession'
}
Import-PSSession -Session ( New-PSSession @Params )
However, I am not understanding how yours is working so I would try this:但是,我不了解您的工作方式,所以我会尝试这样做:
$Credential = Get-Credential
Enter-PSSession -ComputerName DAG01 -Credential $Credential
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
I will note that if you're running PowerShell as the account that is performing the action, you do not need to even specify credentials.我会注意到,如果您以执行操作的帐户身份运行 PowerShell,则您甚至不需要指定凭据。
$creds = Get-Credential $creds = 获取凭据
$sess = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://myserver.mydomain.com/PowerShell/ -Authentication Kerberos -Credential $creds $sess = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://myserver.mydomain.com/PowerShell/ -Authentication Kerberos -Credential $creds
Enter-PSSession $sess输入-PSSession $sess
Get-Mailbox xyz获取邮箱 xyz
Exit出口
Import-PSSession $sess导入 PSSession $sess
Get-Mailbox xyz获取邮箱 xyz
.\DoSomthing.PS1 .\DoSomthing.PS1
Remove-PSSession $sess删除 PSSession $sess
This is from info on https://learn.microsoft.com/en-us/powershell/exchange/exchange-server/connect-to-exchange-servers-using-remote-powershell?view=exchange-ps这是来自https://learn.microsoft.com/en-us/powershell/exchange/exchange-server/connect-to-exchange-servers-using-remote-powershell?view=exchange-ps上的信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.