If you need to automate the attribution of local admin rights, use the following script, that will save you quite a few clicks:
Dim DomainName
Dim UserAccount
Set net = WScript.CreateObject("WScript.Network")
local = net.ComputerName
DomainName = "CONTOSO"
set group = GetObject("WinNT://"& local &"/Administrators")
UserAccount = InputBox( "Please enter the username (first.last) of the local admin or cancel (the user must exist in AD)" )
on error resume next
group.Add "WinNT://"& DomainName &"/"& UserAccount &""
CheckError
sub CheckError
if not err.number=0 then
set ole = CreateObject("ole.err")
MsgBox ole.oleError(err.Number), vbCritical
err.clear
else
MsgBox "User added to the local Admin Group"
end if
end sub
Namaste.

0 comments:
Post a Comment