1
votes

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.

1
Remoting to an Exchange server is explained here: docs.microsoft.com/en-us/powershell/exchange/exchange-server/…Gert Jan Kraaijeveld
Why do you need to use remote PowerShell on the server itself? Can't you just use Add-PSSNapin exchange ; Get-Mailbox right away?Gabriel Luci
@GabrielLuci , I dont need remote powershell on server. In example i showed that it's working in server, but failing when run from remote client.Karthik Hebbar
@GertJanKraaijeveld.. I have tried that as well.. If i use Kerberos it says : WinRM cannot process the request. The following error with errorcode 0x80090311 occurred while using Kerberos authentication: There are currently no logon servers available to service the logon request. If i use basic authentication it says : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available...Karthik Hebbar

1 Answers

0
votes

With PowerShell V2 you've got two approachs for remote commands.

Please refer to the below link:

Can't use Get-Service –ComputerName on remote computer