These are the commands i am trying to execute.
$credential = get-credential
$session = New-PSSession -ComputerName win-j1uti0rc7xx -Credential $credential
invoke-command -Session $session -ScriptBlock { Add-PSSNapin exchange ; Get-Mailbox }
If i run these command on server (where exchange server is deployed) I will get desired output. But if i run same commands on client (Win 7) i would hit below error.
Active Directory operation failed on . The supplied credential for 'Test\Administrator' is invalid. + CategoryInfo : NotSpecified: (:) [], ADInvalidCredentialException + FullyQualifiedErrorId : [Server=WIN-J1UTI0RC7QP,RequestId=17684af8-031d-4511-8142-a3ef49783620,TimeStamp=12/24/2 018 5:30:37 AM] [FailureCategory=Cmdlet-ADInvalidCredentialException] 3B308A1A + PSComputerName : win-j1uti0rc7xx
I have enabled PSRemote, set execution policy remotesigned, added client to trustedhosts on server. Anything else i am missing ?
By the way i think only for exchange cmdlets i am getting these errors. Because if i call
Invoke-Command -Session $session -ScriptBlock { Get-Culture}
I am getting desired output in both machines.
Add-PSSNapin exchange ; Get-Mailbox
right away? – Gabriel Luci