![]() |
| |||||||
| Notices |
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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? | Guest
Posts: n/a
|
|
| | #2 (permalink) | |
| Jason wrote: Quote:
'--------------------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/scr...r/default.mspx | Guest
Posts: n/a
| |
|
| | #3 (permalink) | ||||||||
| 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, Quote:
Quote:
Quote:
Quote:
Quote:
| Guest
Posts: n/a
| ||||||||
|
| | #4 (permalink) | |
| anonymous@discussions.microsoft.com wrote: Quote:
'--------------------8<---------------------- Set oWshNet = CreateObject("WScript.Network") ' computer name sNode = oWshNet.ComputerName ' group name to remove user or group from Set oGroup = GetObject("WinNT://" & sNode & "/Administrators") ' loop through all member of the group For Each oUser In oGroup.Members ' get the name and make it lowercase sGroupEntry = LCase(oUser.Name) If (sGroupEntry = "domain users") Then ' remove entry from group oGroup.Remove oUser.ADsPath End if Next '--------------------8<---------------------- -- 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/scr...r/default.mspx | Guest
Posts: n/a
| |
|
| | #5 (permalink) | |||||
| Thanks Much. These scripts really help. Quote:
Quote:
Quote:
| Guest
Posts: n/a
| |||||
|
| | #6 (permalink) | |
| You can also do this pretty easily via the "net localgroup" command (though this isn't really VBScript, you could call it from a vbs): net localgroup Administrators /add DOMAIN\USERNAME -- Please reply in newsgroup. This posting is provided "AS IS" with no warranties, and confers no rights. "Jason" <jason.brimhall@questar.com> wrote in message news:015a01c4904e$c8fa1d20$a401280a@phx.gbl... Quote:
| Guest
Posts: n/a
| |
|
![]() |
| Tags |
| None |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| remotely query group membership of machine via script/wmi | sumGirl | Windows XP WMI | 3 | 11-30-2004 01:40 PM |
| programs installled either as local/network admin will not run as domain user | brenden | Windows XP Configuration & Management | 0 | 08-27-2004 10:54 AM |
| Standard user (power user group) | Ray | Windows XP Configuration & Management | 1 | 07-31-2004 07:08 PM |
| Make local computer user domain user too? | Ken Very Big Liar | Windows XP Help & Support | 1 | 10-02-2003 02:16 AM |
| Creating a Logon Script for a local user | Neil | Windows XP New Users | 0 | 07-15-2003 07:47 PM |