Im trying to execute microsoft exchange command from remote client using winrm. Connection established successfully, im able to execute basic commands(Get-Date..) and able to execute some commands related to AD. But when it comes to Exchange related commands(Get-Mailbox) it fails with below error.
Active Directory operation failed on . The supplied credential for ‘domain/user’ is invalid.
+ CategoryInfo : NotSpecified: (:) [], ADInvalidCredentialException
any help is apprecited…
Note: i have tried below command before executing above command.
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn. no error while snapin.
You need to pass the credentials into the PSSession and then execute the actual commands.
$Credential = Get-Credential
Enter-PSSession -ComputerName HYDIN001 -Credential $Credential
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
Get-Mailbox -ResultSize unlimited