Script that will place a Domain Local group into a Local group

Script that will place a Domain Local group into a Local group

Post by bno1MG1 » Sat, 13 May 2006 05:33:02


Does anyone have any idea as to how I can create a VBS script that will place
a Domain Local group into a Local group?

Any and all help would be appreciated very much.

--
Randy Jackman
EDS
System Administrator
 
 
 

Script that will place a Domain Local group into a Local group

Post by Richard Mu » Sat, 13 May 2006 06:17:49


Hi,

In VBScript you must use the WinNT provider. You bind to both the local
group and the domain local group. I use the Add method of the local group
object to add the domain group as a member. For example:

Option Explicit
Dim objLocalGroup, objDomainGroup

Set objLocalGroup = GetObject("WinNT://MachineName/LocalGroupName,group")
Set objDomainGroup = GetObject("WinNT://DomainName/DomainGroupName,group")

If Not objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
objLocalGroup.Add(objDomainGroup.AdsPath)
End If

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.yqcomputer.com/