So trying to run Exchange Management Shell Locally using PSSession, but getting an AD Operation Failure.
Here are my steps
1)open PSmodule as Admin
2)
Enter-PSSession -ComputerName DAG01 -Credential domain\user
3)
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
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
Weird thing is that if I RDP with the same credentials into the DAG and run Exchange Management Shell, everything works fine.
This can be used to import a PSSession from your remote exchange server.
$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.