PowerShell: Invoke-Command

VertigoRay/ November 29, 2012/ Uncategorized/ 0 comments

Had some issues with Invoke-Command today:

[PS] H:>Invoke-Command -ScriptBlock { get-process } -ComputerName MyScriptServer

It gave me the following error:

Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authentication: The network path was not found.

 Possible causes are:

  -The user name or password specified are invalid.

  -Kerberos is used when no authentication method and no user name are specified.

  -Kerberos accepts domain user names, but not local user names.

  -The Service Principal Name (SPN) for the remote computer name and port does not exist.

  -The client and remote computers are in different domains and there is no trust between the two domains.

 After checking for the above issues, try the following:

  -Check the Event Viewer for events related to authentication.

  -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.

 Note that computers in the TrustedHosts list might not be authenticated.

   -For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.

    + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException

    + FullyQualifiedErrorId : PSSessionStateBroken

“The network path was not found” is clearly a DNS resolution error. I would venture to say there is a Name Suffix Routing issue.

The -ComputerName property description says that NETBIOS name should work, but it does not in my testing in my environment. The FQDN is another option for the -ComputerName property and fixed this error for me when done in all lowercase.

Try using (use your FQDN, of course):

Invoke-Command -ComputerName myscriptserver.vertigion.com 

Note: Notice it’s in all lowercase. Using camel case (serverA.vertigion.com) failed with the same error.

Note: I did NOT have the issue with the Enter-PSSession command. I believe there’s a bug (or at least a blatant inconsistency) with Invoke-Command.

Another option would be to create the PSSession first (New-PSSession) and reference it.  This is the option I used as it also prevents constant renegotiation when sending multiple commands back-to-back.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*