I wrote a script that adds groups/users to local admin group on a list of pc's. Ex: you need a newly created group to be in the admin group on a list of pc's. This will do it. I use a command line tool from Windows 2000 resource kit called cusrmgr.exe in order to make this work. Hope this helps.
Here is my code:
code:
BREAK ON
;DEBUG ON
;========================
;= Variables To Edit =
;========================
;NOTE: I use a domain admin account instead of my own to run this script so I type my other account info below.
;Username Note: This should be the local admin account of the remote PC's.
$USERNAME = "administrator"
;Password Note: This should be the local admin password of the remote PC's.
;Special Note: @, %, $ are special characters. If your password contains them please type them twice in a row.
;EX: "$Test@_$" = "$$Test@@_$$"
$PWD = "mypassword"
;Drive Letter: This should be the drive letter the script will use to connect to the remote PC's.
$drive = "y"
;========================
;= Do Note Edit Below =
;========================
$ResultCode = SetTitle ("Adding Global Groups")
;Configure Production Local Groups
SHELL "%COMSPEC% /C net use $drive: /d >NUL"
CLS
IF OPEN (1,"PCLIST.TXT",0) = 0
SHELL "%COMSPEC% /C echo PC Name,DOMAIN\Desktop Central,DOMAIN\PDSNE,DOMAIN\PDSSEMA,DOMAIN\PDSWR,DOMAIN\AV Security>> INSTALL_LOG.CSV"
$LINEINFO = READLINE(1)
WHILE @ERROR = 0
? "Pcname: $LINEINFO"
IF EXIST ("\\$LINEINFO\c$")
SHELL "%COMSPEC% /C net use $drive: \\$LINEINFO\c$ /USER:$LINEINFO\$USERNAME $PWD >NUL"
IF EXIST ("$drive:")
$DOMAINdtc = ""
$DOMAINpdsne = ""
$DOMAINpdssema = ""
$DOMAINpdswr = ""
$DOMAINavs = ""
;Add DOMAIN\Desktop Central to Administrators
SHELL '%COMSPEC% /C CUSRMGR -u "DOMAIN\Desktop Central" -m "\\$LINEINFO" -alg "Administrators" >NUL'
SELECT
CASE @ERROR = "0"
$DOMAINdtc = "Successfully added to the group"
CASE @ERROR = "1378"
$DOMAINdtc = "Already in the group"
CASE @ERROR = "1722"
$DOMAINdtc = "No PC Found"
CASE @ERROR = "5"
$DOMAINdtc = "Access Denied"
CASE @ERROR = "3"
$DOMAINdtc = "Can not get SID of group"
CASE 1
$DOMAINdtc = "Weird Error"
ENDSELECT
;Add DOMAIN\PDSNE to Administrators
SHELL '%COMSPEC% /C CUSRMGR -u "DOMAIN\PDSNE" -m "\\$LINEINFO" -alg "Administrators" >NUL'
SELECT
CASE @ERROR = "0"
$DOMAINpdsne = "Successfully added to the group"
CASE @ERROR = "1378"
$DOMAINpdsne = "Already in the group"
CASE @ERROR = "1722"
$DOMAINpdsne = "No PC Found"
CASE @ERROR = "5"
$DOMAINpdsne = "Access Denied"
CASE @ERROR = "3"
$DOMAINpdsne = "Can not get SID of group"
CASE 1
$DOMAINpdsne = "Weird Error"
ENDSELECT
;Add DOMAIN\PDSSEMA to Administrators
SHELL '%COMSPEC% /C CUSRMGR -u "DOMAIN\PDSSEMA" -m "\\$LINEINFO" -alg "Administrators" >NUL'
SELECT
CASE @ERROR = "0"
$DOMAINpdssema = "Successfully added to the group"
CASE @ERROR = "1378"
$DOMAINpdssema = "Already in the group"
CASE @ERROR = "1722"
$DOMAINpdssema = "No PC Found"
CASE @ERROR = "5"
$DOMAINpdssema = "Access Denied"
CASE @ERROR = "3"
$DOMAINpdssema = "Can not get SID of group"
CASE 1
$DOMAINpdssema = "Weird Error"
ENDSELECT
;Add DOMAIN\PDSWR to Administrators
SHELL '%COMSPEC% /C CUSRMGR -u "DOMAIN\PDSWR" -m "\\$LINEINFO" -alg "Administrators" >NUL'
SELECT
CASE @ERROR = "0"
$DOMAINpdswr = "Successfully added to the group"
CASE @ERROR = "1378"
$DOMAINpdswr = "Already in the group"
CASE @ERROR = "1722"
$DOMAINpdswr = "No PC Found"
CASE @ERROR = "5"
$DOMAINpdswr = "Access Denied"
CASE @ERROR = "3"
$DOMAINpdswr = "Can not get SID of group"
CASE 1
$DOMAINpdswr = "Weird Error"
ENDSELECT
;Add DOMAIN\AV Security to Administrators
SHELL '%COMSPEC% /C CUSRMGR -u "DOMAIN\AV Security" -m "\\$LINEINFO" -alg "Administrators" >NUL'
SELECT
CASE @ERROR = "0"
$DOMAINavs = "Successfully added to the group"
CASE @ERROR = "1378"
$DOMAINavs = "Already in the group"
CASE @ERROR = "1722"
$DOMAINavs = "No PC Found"
CASE @ERROR = "5"
$DOMAINavs = "Access Denied"
CASE 1
$DOMAINavs = "Weird Error"
ENDSELECT
ELSE
$DOMAINdtc = "Access Denied"
ENDIF
;Log pcname and status to INSTALL_LOG.CSV
SHELL "%COMSPEC% /C echo $LINEINFO,$DOMAINdtc,$DOMAINpdsne,$DOMAINpdssema,$DOMAINpdswr,$DOMAINavs>> INSTALL_LOG.CSV"
ELSE
SHELL "%COMSPEC% /C echo $LINEINFO,Unavailable>> INSTALL_LOG.CSV"
ENDIF
SHELL "%COMSPEC% /C net use $drive: /d >NUL"
$LINEINFO = READLINE(1)
LOOP
$RC = CLOSE (1)
ENDIF
EXIT