Archived from groups: microsoft.public.windowsxp.configuration_manage (
More info?)
To take this one step further, the DOMAIN USERS group had
been added to the Local Admin group. How can I, via
vbscript, remove that group from the workstations?
Thanks,
>-----Original Message-----
>Jason wrote:
>
>> I am looking to add a domain user to the local admin
group
>> via vb scripting. I have a script to add a local user
to
>> the local group but am uncertain how to modify
>> appropriately to pull the domain user.
>>
>> Any help?
>Hi
>
>
>'--------------------8<----------------------
>
>Set oWshNet = CreateObject("WScript.Network")
>
>sUser = "fill in some domain user name here"
>
>sNetBIOSDomain = oWshNet.UserDomain
>sComputer = oWshNet.ComputerName
>
>Set oGroup = GetObject("WinNT://" & sComputer
& "/Administrators,group")
>Set oUser = GetObject("WinNT://" & sNetBIOSDomain & "/" &
sUser & ",user")
>
>' suppress errors in case the user is already a member
>On Error Resume Next
>oGroup.Add(oUser.ADsPath)
>On Error Goto 0
>'--------------------8<----------------------
>
>
>If the computers are in another domain than the user you
>want to add, you will need to hard code the domain name
>the user belongs to in the variable "sNetBIOSDomain".
>
>
>
>--
>torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
>Administration scripting examples and an ONLINE version of
>the 1328 page Scripting Guide:
>http://www.microsoft.com/technet/scriptcenter/default.mspx
>.
>