Jump to content

Help!


Recommended Posts

ok, I am probably becoming a pain in the butt, this is the last piece of my script that I need and I am so frustrated as to why it will not work. here is the code that works with a username:

------------------------------------------------------------------------------------

Run(@ComSpec & " /c net localgroup administrators tedescoj /add")

------------------------------------------------------------------------------------

here is the code that will not work with the variable the computername is the username:

-------------------------------------------------------------------------------------------------------

$comp = @computername

Run(@ComSpec & " /c net localgroup administrators " & $comp & " /add", "", @SW_HIDE)

-------------------------------------------------------------------------------------------------------

Thanks for looking. I need this before work on Monday and this is why I am being suck a pain in the butt.

Jay

Link to comment
Share on other sites

ok, I am probably becoming a pain in the butt, this is the last piece of my script that I need and I am so frustrated as to why it will not work. here is the code that works with a username:

------------------------------------------------------------------------------------

Run(@ComSpec & " /c net localgroup administrators tedescoj /add")

------------------------------------------------------------------------------------

here is the code that will not work with the variable the computername is the username:

-------------------------------------------------------------------------------------------------------

$comp = @computername

Run(@ComSpec & " /c net localgroup administrators " & $comp & " /add", "", @SW_HIDE)

-------------------------------------------------------------------------------------------------------

Thanks for looking. I need this before work on Monday and this is why I am being suck a pain in the butt.

Jay

Why are you trying to add a computer account to the local administrators group...that will not work with that net command...if you where meaning to add the logged in user to the local admin group, that won't work either unless that user is already a local admin...then what is the point...

If you are trying to add the logged in user to the local admin group, if should be something like this...

$user = @UserName

Run(@ComSpec & " /c net localgroup administrators" & $user & " /add", "", @SW_HIDE)

Is this what you are trying to accomplish?

Edited by Gnat
Link to comment
Share on other sites

Why are you trying to add a computer account to the local administrators group...that will not work with that net command...if you where meaning to add the logged in user to the local admin group, that won't work either unless that user is already a local admin...then what is the point...

If you are trying to add the logged in user to the local admin group, if should be something like this...

$user = @UserName

Run(@ComSpec & " /c net localgroup administrators" & $user & " /add", "", @SW_HIDE)

Is this what you are trying to accomplish?

I am sorry, let me explain a little better, We have 290 student's comming in to our school and all getting new laptops. I wrote a script that will change the computer name to their login name once they type in their login name in the input box. We do this so we can keep track of who owns wich computers. The users are already in active directory but I need to add them to the local admin group on the computer. So since the computer is already set to their login name I want to take advantage of that and use that as the variable to add it to the local admin group. I hope this helps.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...