tedescoj Posted April 13, 2007 Share Posted April 13, 2007 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 More sharing options...
Gnat Posted April 13, 2007 Share Posted April 13, 2007 (edited) 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 = @computernameRun(@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.JayWhy 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 = @UserNameRun(@ComSpec & " /c net localgroup administrators" & $user & " /add", "", @SW_HIDE)Is this what you are trying to accomplish? Edited April 13, 2007 by Gnat Link to comment Share on other sites More sharing options...
tedescoj Posted April 13, 2007 Author Share Posted April 13, 2007 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 = @UserNameRun(@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 More sharing options...
jvanegmond Posted April 13, 2007 Share Posted April 13, 2007 Why did you make 2 topics? The question has even been answered several times, just Search! github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts