using powershell Invoke-command to execute DOS command on remote machine

Hi,

We have noticed on issue while executing the dos command on the remote machine using invoke-command powershell commandlet.

While trying to execute the DOS command on remote machines and if the count of remote machines is more than and equal to 3, then randomly for one machine the response is not received. This issue is noticed in invoke-command commandlet while running from powershell console as well as from c# program leveraging system.management.automation.powershell object.

Please let us know if this some know issue or I am missing some configuration.

Thanks,

Rahul

June 30th, 2015 1:37am

In general it will not be the problem running a DOS command over a remote connection via PowerShell, it will be with a high probability the remote connection itself. Bad to say, there are lot reasons that a connection does not work.  

There three basic categories for failure:

  • Inhibit the connection where PowerShell is innocent are Firewalls and AntiVirus products
  • The configuration on the WinRM (Windows Remote Management) on local and remote client site
  • And often the permissions (don't have the permissions on a remote Server)

To localitze your problem, start with checking the firewall. Then review your WinRM configurations. Test the connections: First try to connect the local machine to the local machine. When this works the problem is 100% up to the remote site. When you assume that the configuration is good, concentrate on the permission. Being an administrator on both sides is helpful to identify the problem.

I hope that recipe is helpful for you - let me know if you solved your problem.      

  

Free Windows Admin Tool Kit Click here and download it now
June 30th, 2015 2:36am

In general it will not be the problem running a DOS command over a remote connection via PowerShell, it will be with a high probability the remote connection itself. Bad to say, there are lot reasons that a connection does not work.  

There three basic categories for failure:

  • Inhibit the connection where PowerShell is innocent are Firewalls and AntiVirus products
  • The configuration on the WinRM (Windows Remote Management) on local and remote client site
  • And often the permissions (don't have the permissions on a remote Server)

To localitze your problem, start with checking the firewall. Then review your WinRM configurations. Test the connections: First try to connect the local machine to the local machine. When this works the problem is 100% up to the remote site. When you assume that the configuration is good, concentrate on the permission. Being an administrator on both sides is helpful to identify the problem.

I hope that recipe is helpful for you - let me know if you solved your problem.      

  

June 30th, 2015 2:40am

In general it will not be the problem running a DOS command over a remote connection via PowerShell, it will be with a high probability the remote connection itself. Bad to say, there are lot reasons that a connection does not work.  

There three basic categories for failure:

  • Inhibit the connection where PowerShell is innocent are Firewalls and AntiVirus products
  • The configuration on the WinRM (Windows Remote Management) on local and remote client site
  • And often the permissions (don't have the permissions on a remote Server)

To localitze your problem, start with checking the firewall. Then review your WinRM configurations. Test the connections: First try to connect the local machine to the local machine. When this works the problem is 100% up to the remote site. When you assume that the configuration is good, concentrate on the permission. Being an administrator on both sides is helpful to identify the problem.

I hope that recipe is helpful for you - let me know if you solved your problem.      

  

  • Edited by Guy Jascht Tuesday, June 30, 2015 6:36 AM
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2015 6:34am

In general it will not be the problem running a DOS command over a remote connection via PowerShell, it will be with a high probability the remote connection itself. Bad to say, there are lot reasons that a connection does not work.  

There three basic categories for failure:

  • Inhibit the connection where PowerShell is innocent are Firewalls and AntiVirus products
  • The configuration on the WinRM (Windows Remote Management) on local and remote client site
  • And often the permissions (don't have the permissions on a remote Server)

To localitze your problem, start with checking the firewall. Then review your WinRM configurations. Test the connections: First try to connect the local machine to the local machine. When this works the problem is 100% up to the remote site. When you assume that the configuration is good, concentrate on the permission. Being an administrator on both sides is helpful to identify the problem.

I hope that recipe is helpful for you - let me know if you solved your problem.      

  

  • Edited by Guy Jascht Tuesday, June 30, 2015 6:36 AM
June 30th, 2015 6:34am

In general it will not be the problem running a DOS command over a remote connection via PowerShell, it will be with a high probability the remote connection itself. Bad to say, there are lot reasons that a connection does not work.  

There three basic categories for failure:

  • Inhibit the connection where PowerShell is innocent are Firewalls and AntiVirus products
  • The configuration on the WinRM (Windows Remote Management) on local and remote client site
  • And often the permissions (don't have the permissions on a remote Server)

To localitze your problem, start with checking the firewall. Then review your WinRM configurations. Test the connections: First try to connect the local machine to the local machine. When this works the problem is 100% up to the remote site. When you assume that the configuration is good, concentrate on the permission. Being an administrator on both sides is helpful to identify the problem.

I hope that recipe is helpful for you - let me know if you solved your problem.      

  

  • Edited by Guy Jascht Tuesday, June 30, 2015 6:36 AM
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2015 6:34am

Thanks for the information provided

Actually when we tried for more than 2 remote machines e.g. 3, randomly for one (and exactly one) the response is not received. So if try again, not necessary that the response from the same machine will be missing, response from one among the 3 will be missing. And again, if I individually try for the machine (whose response was missing while running in group), then the response is received. So there is no issue in reaching or accessing it. This is what surprising me

June 30th, 2015 8:52am

By default in WSMAN only 5 concurrent remote sessions are allowed. With Invoke-Command a temporary session is opened. I know that when a session is removed the resources are not immediately freed (when disconnected never!). Maybe that can be a starter to solve for your problems. As test serialize your invoked commands with gaps (15 secs - Start-Sleep -s 15) between. 

A good link regarding sessions is: Administrator's Guide to Powershell Remoting . Look at the chapter "Temporary Sessions"

 Let me know if that helps.  
Free Windows Admin Tool Kit Click here and download it now
July 1st, 2015 2:25am

thanks for the pointers, let me go through the guide...
July 9th, 2015 9:07am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics