I have one exchange server and a windows 7 machine.
W.R.T remote execution
Server - Exchange Server (Win server 2012) Client - Win 7 machine
I want to run scripts which are present in client machine on remote machine (exchange/ win server 2012). But these are failing with error cmdlets not found.
So to check quickly i tried to invoke normal powershell cmdlets as well as exchange cmdlets and found that only exchange cmdlets are failing. However if i run same cmdlet on server (exchange) it gives me expected output.
Questions
- Won't exchange cmdlets work in remote powershell ?
- I tried with different session type having exchange server as connection URL but facing errors there as well.
Attached below sample test outputs.
Help me how to proceed further !!
On remote client (Win 7 machine)
PS C:\Users\Administrator> invoke-command -Session $session -ScriptBlock { ls }
returns:
Directory: C:\Users\Administrator\Documents
Mode LastWriteTime Length Name PSComputerName
---- ------------- ------ ---- --------------
d----- 12/2/2018 12:10 PM WindowsPowerShell 10.76.68.251
But the Exchange cmdlets do not work
PS C:\Users\Administrator> invoke-command -Session $session -ScriptBlock { Get-Mailbox }
The term 'Get-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (Get-Mailbox:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : 10.76.68.251
Server - Exchange / Server 2012
PS C:\Users\Administrator\Downloads\custom scripts> Get-Mailbox
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- -----------------
Administrator Administrator win-j1uti0rc7qp Unlimited
DiscoverySearchMailbox... DiscoverySearchMa... win-j1uti0rc7qp 50 GB (53,687,091,200 bytes)
Test with Exchange Server URL in Connection URI
Test 1
PS C:\Users\Administrator> $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://10.76.68.251/PowerShell/ -Authentication Kerberos -Credential $credential
Error:
New-PSSession : [10.76.68.251] Connecting to remote server 10.76.68.251 failed with the following error message : The WinRM client cannot process the request. Kerberos authentication cannot be used when the destination is an IP address. Specify a DNS or NetBIOS destination or specify Basic or Negotiate authentication. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:13 + $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri h ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : -2144108277,PSSessionOpenFailed
Test 2
PS C:\Users\Administrator> $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://10.76.68.251/PowerShell/ -Credential $credential
Error:
New-PSSession : [10.76.68.251] Connecting to remote server 10.76.68.251 failed with the following error message : The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:13 + $session1 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri h ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession],PSRemotingTransportException + FullyQualifiedErrorId : -2144108297,PSSessionOpenFailed