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.
LVL 1
structuredwebAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Coralon
Thomas GrassiSystems AdministratorCommented:
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
Lionel MMSmall Business IT ConsultantCommented:
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

structuredwebAuthor Commented:
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?
Lionel MMSmall Business IT ConsultantCommented:
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?
structuredwebAuthor Commented:
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.
Lionel MMSmall Business IT ConsultantCommented:
if you look in the upper left hand corner the title of CMD will either be command prompt or Administrator: Command prompt
Thomas GrassiSystems AdministratorCommented:
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
structuredwebAuthor Commented:
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.
Thomas GrassiSystems AdministratorCommented:
CoralonCommented:
Looking at this in more depth.. here's a couple of things to try:

1. drop the -i  do you really need it to be interactive with the logged in user?  Generally that's not required, depending on what your batch file is doing.  

2. Use a cmd.exe wrapper in your psexec.. see if that works?
PsExec.exe \\machine2-2012 -i -u 2012-DOMAIN\administrator -p xxxxxx cmd.exe /c \\remote-server2\path\some-script.bat

Coralon

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
structuredwebAuthor Commented:
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.
CoralonCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.