Link to home
Start Free TrialLog in
Avatar of structuredweb
structuredweb

asked on

PSexec cannot execute commands on a remote UNC path for some environments

We have an existing system, in which we remotely execute scripts on a machine which resides in remote Windows 2003 domain using this type of commands:

PsExec.exe \\machine1-2003 -i -u 2003-DOMAIN\administrator -p xxxxxx \\remote-server1\path\some-script.bat


We are moving to a new environment, in which the domain is Windows 2012 level, and this command now does not work when we try to use a Windows 2003 machine in the new domain.

PsExec.exe \\machine2-2003 -i -u 2012-DOMAIN\administrator -p xxxxxx \\remote-server2\path\some-script.bat

PSExec returns "Access Denied" error. I can only run local commands (C:, D:)

However, I can run the same command against a Windows 2012 client:

PsExec.exe \\machine2-2012 -i -u 2012-DOMAIN\administrator -p xxxxxx \\remote-server2\path\some-script.bat

the script we call calls several scripts, and is not meant to be run on 2012 machines; I played with using "net use" as part of the PSExec command and was able to run simple commands, but the script I need to run calls many other scripts and none will work unless they all change to use the same drive letter the "net use" references and that would be a nightmare; the same scripts are also execute directly on the remote machines.

any idea? I saw references to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\Scripting\Default Impersonation Level but its set to the same value (3) on the 2003 and 2012 machines. The DC uses default security settings for all machines.

any ideas?

EDIT: I just tried this and it works:
c:\>PsExec.exe \\machine2-2003 -i -u 2012-DOMAIN\administrator -p xxxxxx cmd
( i am logged in and now the window is on the remote machine)
C:\WINDOWS\system32>\\remote-server2\path\some-script.bat

so if just run cmd, my command prompt switched to the remote, and then i was able to run the script on the UNC path. so why can't i run it in one command? i should stress that the PSExec is part of a script system and thus we cannot have need for interactive users.
Avatar of Coralon
Coralon
Flag of United States of America image

Do you maybe need the -h switch to deal with UAC?

Coralon
try using the -h option on the psexec command line the runs an elevated level on the remote machine

for the access denied take a look at this

http://stackoverflow.com/questions/828432/psexec-access-denied-errors

HTH
so why can't i run it in one command?
Because you are providing psexec access to \\machine2-2003 but then trying to run the batch file on a different \\remote-server2 run the command to the \\remote-server2 directly with psexec
Avatar of structuredweb
structuredweb

ASKER

the -h doesn't work. I understand its not relevant when the target is 2003. I even tried the -l, no luck.

Thomas Grassi - I tried the options in your link, registry, local security policy (that i tried before) and none worked. just the part about the admin$ i didn't do - it looks a bit sketchy, and from all I read should not matter, the user i am logged in to the target is the domain administrator, and it belongs to the Administrators group on the target.

lionelmm - I should have mentioned remote-server2  is actually a NAS device, i cannot login to it.

ALL - i should repeat, this setup is working perfectly on the old data center, and the only difference i see is that the in the new data center the domain itself is 2012 based.
also what about the fact that i can run the script when i run PSExec in interactive mode, that is "cmd" only and then run the command on the UNC share?
what about the fact that i can run the script when i run PSExec in interactive mode, that is "cmd" only and then run the command on the UNC share?

This usually then is a permissions issue; are you using the same user in interactive mode as this user -u 2012-DOMAIN\administrator -p xxxxxx in your scripts? and is the CMD in interactive mode an elevated (admin) command prompt?
i am using the same user in interactive mode, when logging to the machine on Remote Desktop, etc. Initially i was using another domain user but this was not working so i wanted to make sure i can get it working with the domain admin first.

and is the CMD in interactive mode an elevated (admin) command prompt?
How do i know? I run the PSExec as described above with just the "cmd" command.
if you look in the upper left hand corner the title of CMD will either be command prompt or Administrator: Command prompt
Have you thought about adding this scripts to task scheduler?

Do they run on a regular basis or on demand?

Either way they can be defined in Task Scheduler and then run schtasks remotely to run the jobs

https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx

HTH
Thomas, unfortunately its on demand and a highly random schedule. we might not issue one for days and some days we will issue 50 calls. also the parameters for the scripts vary, so I don't see how could we run sched tasks remotely this way.


more data: we have captured packets in Wireshark and see the following
==> NTLM - negotiation request,
<== Negotiation failure
==> NTLMSSP_negotiate
<== error, more processing required

At this point, on 2012 we see now:
==> NTLMSSP_AUTH using the domain\machinename$

and on on 2003  - we see now:
==> NTLMSSP_AUTH with a null credentials, which fails.


We cannot figure out yet why NTLM - negotiation request and NTLMSSP_negotiate fail from both machines. Even with the 2012 this is far from an optimal situation and we have seen slow execution. But we need the 2003 to work as well.
ASKER CERTIFIED SOLUTION
Avatar of Coralon
Coralon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
removing the -i flag did not solve the issue.

however, running this using a cmd.exe /c does! i'm able to run my scripts now!  

thanks a bunch! maybe i should have realized that by running cmd.exe and then manually entering the commands worked, so this should have worked. as well.
Absolutely.. I use psexec \\machine cmd.exe *all* the time :-)  I was just looking at it from using it in a scripted/automated fashion.

Coralon