Re: Add domain user to local group script troubleshoot
From: Richard Mueller [MVP] (rlmueller-NOSPAM_at_ameritech.NOSPAM.net)
Date: 03/26/04
- Next message: JB Fields: "Read-only registry keys?"
- Previous message: mtothej: "Re: Add domain user to local group script troubleshoot"
- In reply to: mtothej: "Re: Add domain user to local group script troubleshoot"
- Next in thread: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Reply: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 25 Mar 2004 19:43:13 -0600
mtothej wrote:
> Richard, thanks for the help. The WinNT path to the domain user works
great. Here's the catch; it works great when I'm already a member of the
local admins group. I have admin rights to my OU (we're a branch office),
and thus my Computers OU underneath, but am not a domain admin and so am not
by default in the local admins group of each computer. Is there a script
which would add a user (or group) to the local admins group of all computers
in an OU - I guess this would have to be run via Group Policy and dropped on
the computers as they booted? Otherwise it could be run by a domain admin I
guess. Any ideas? Thx...
Hi,
Actually, if you use Group Policy, the best way is to use a Startup script.
Startup scripts run with System privileges on the local computer (before any
user logs on) and can add members to the local Administrators group. Best
practice would be to add a domain group to the local Administrators group on
every PC. This way, membership can be easily modified in the future without
touching the machines again. Group Policy can be applied to the OU.
One other consideration is that it is cleaner to add the group once, and not
attempt to repeat the process. In the past I have used code similar to
below, which only adds the domain group to the local group if it is not
already a member:
' Specify AdsPath of domain group to be added to
' local Administrators group.
strDomainGroup = "WinNT://MyDomain/ComputerAdmins,group"
' Bind to domain group.
Set objDomainGroup = GetObject(strDomainGroup)
' Retrieve local computer NetBIOS name.
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
' Bind to local Administrators group.
Set objLocalGroup = GetObject("WinNT://" & strComputer _
& "/Administrators,group")
' Check if domain group already a member.
If Not objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
' Add domain group to local group.
objLocalGroup.Add(objDomainGroup.AdsPath)
End If
-- Richard Microsoft MVP Scripting and ADSI HilltopLab web site - http://www.rlmueller.net --
- Next message: JB Fields: "Read-only registry keys?"
- Previous message: mtothej: "Re: Add domain user to local group script troubleshoot"
- In reply to: mtothej: "Re: Add domain user to local group script troubleshoot"
- Next in thread: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Reply: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|