Powershell: Using psexec with UNC path gives “access is denied”

powershellpsexecremote-access

I am trying to run a powershell command like this:

psexec \\MachineB "\\MachineB\drops\Func2WebSiteOnline.bat"

I get this error:

PsExec could not start \\MachineB\drops\Func2WebSiteOnline.bat on
MachineB: Access is denied.

I have tried the following things:

  1. run powershell in "Administrator" mode
  2. Run the powershell command with "-u Domain\user -p password" params

Neither of those help. However, I can run simple commands against machineB like this:

psexec \\MachineB net stop dcache

and that works just fine.

Any thoughts on how I can run that batch file above against MachineB?

Thanks

Best Answer

I found a somewhat unconventional way to solve it.

psexec \\MachineB -u domain\user -p password cmd /c "cd /d I:\drops\Func2 && func2web.bat"