Sign in to follow this  
Followers 0
Prodigus

What's wrong with this syntax? /e beating head against desk

5 posts in this topic

$sCmd2run = 'psexec \\'& $var1 & 'net localgroup administrators /add' '"sleh\'&$var2"'

$sErrorStatus = RunWait($sCmd2Run, @ScriptDir, @SW_HIDE)

I just can't seem to get all my ' and " in the right place on this one.... GRRRRRR

Share this post


Link to post
Share on other sites



hmm... don't know the problem with the code but it looks to me like someone is trying to get himself administrative(sp?) rights on his computer...XD

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$sCmd2run = 'psexec \\'& $var1 & 'net localgroup administrators /add' '"sleh\'&$var2"'

$sErrorStatus = RunWait($sCmd2Run, @ScriptDir, @SW_HIDE)

I just can't seem to get all my ' and " in the right place on this one.... GRRRRRR

Missing an ampersand and a space after /add, and you have an odd count of single-quotes:

$sCmd2run = 'psexec \\' & $var1 & 'net localgroup administrators /add "sleh\' & $var2 & '"'
$sErrorStatus = RunWait($sCmd2Run, @ScriptDir, @SW_HIDE)

Your command parts (in single quotes) are:

'psexec \\'

$var1

'net localgroup administrators /add "sleh\'

$var2

'"' (a double-quote within single-quotes)

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

hmm... don't know the problem with the code but it looks to me like someone is trying to get himself administrative(sp?) rights on his computer...XD

PSEXEC is not exactly a hack, becuase you have to authenticate for any operation performed. It is however a security problem, because it passes all parameters (including passwords) in clear text. This is not a problem if you are logged in to a domain or an identical account on the computer sending the PSEXEC command as an admin on the target, and don't have to pass any password over the commmand line, such as to add a user to a group.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank You!

It's a function of a script I'm writing to gather all of my servers names from AD (about 300) then create Global Groups for each of them to contain the local admins. This is just to add each of those global groups to the local admins group on each server.... Then populate the global group with the domain users who are now members of the local groups. I want to be able to manage local admins from a higher level is all...

Thanks again!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0