Forum Discussion

Ken_SQLDBA's avatar
Ken_SQLDBA
Copper Contributor
Mar 04, 2022

INVOKE-COMMAND to remote server works on one server but not another

Hello everyone, I've got a problem with INVOKE-COMMAND where it works with one server but not another.

 

NEX-SUPD106 is a server that runs an application called “ArielDB” on one of the non-production environments of our pension administration system.  This non-production system is known as “SUP” and I can use remote desktop to connect to NEX-SUPD106 using the svcOctopusSUP account as it is in the Administrators group.  If I run the following code in a PowerShell window on my desktop and supply the password for svcOctopusSUP, it works and the Security event view shows a successful login (image attached).

 

 

$global:Env="SUP"; $global:CRM_host="NEX-SUPD106"
$svcCRMOther_cred = Get-Credential -Credential APACORP\svcOctopus$global:Env
$global:CRM_session = New-PSSession -ComputerName $global:CRM_host -Credential $svcCRMOther_cred

Invoke-Command -Session $global:CRM_session -ScriptBlock {
  param($p_Env, $p_CRM_host)
  write-Output "This is inside the Invoke-Command."
  } -ArgumentList ($global:Env, $global:CRM_host)

This is inside the Invoke-Command.

 

 

NEX-SUPD118 is a server that runs Microsoft Dynamics CRM for the same “SUP” non-production pension administration environment and I can connect using remote desktop to that server using the svcCRMOtherSUP account as it is in the Administrators group on the server.  Weirdly, if I run the same PowerShell code but for the CRM server and CRM account, it fails:

 

 

$global:Env="SUP"; $global:CRM_host="NEX-SUPD118"
$svcCRMOther_cred = Get-Credential -Credential APACORP\svcCRMOther$global:Env
$global:CRM_session = New-PSSession -ComputerName $global:CRM_host -Credential $svcCRMOther_cred

Invoke-Command -Session $global:CRM_session -ScriptBlock {
  param($p_Env, $p_CRM_host)
  write-Output "This is inside the Invoke-Command."
  } -ArgumentList ($global:Env, $global:CRM_host)

New-PSSession : [NEX-SUPD118] Connecting to remote server NEX-SUPD118 failed with the following error message : WinRM cannot process the request.
The following error with errorcode 0x80090322 occurred while using Kerberos authentication: An unknown security error occurred. 
<lines deleted>
At line:3 char:23
+ ... M_session = New-PSSession -ComputerName $global:CRM_host -Credential  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : -2144108387,PSSessionOpenFailed
Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument that is not null or empty,
and then try the command again.
At line:4 char:25
+ Invoke-Command -Session $global:CRM_session -ScriptBlock {
+                         ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand

 

 

There is something that’s preventing the simple INVOKE-COMMAND from connecting to NEX-SUPD118.  The accounts I’m using are both in the local Administrators group on their server and I can connect to each server using the respective account.  The same code works on one server but fails on another.

 

Any suggestions on where to look / what to check would be appreciated.

 

Ken

Resources