Adding a Domain Global group to a machine local group in Windows 2000 
Author Message
 Adding a Domain Global group to a machine local group in Windows 2000

I have written the following code to add a user to the from the domain to a
local group on a workstation.  I would like to make two changes to the
script.  First, I would like to adapt the code to add a domain global group
to a local group on the machine.  Second, when setting the strLocalMachine
string I would like to pull the local computer name system variable from the
workstation into this so that it is dynamic.  Any help is appreciated.

strPDC="CHESVA14"
strLocalMachine="lt00972"
strUser="user"
strGroup="power users"
Set oDomain = GetObject("WinNT://" & strLocalMachine)
Set oGroup = oDomain.GetObject("Group", strGroup)
oGroup.Add ("WinNT://" & strPDC & "/" & strUser)
Set oDomain=Nothing
Set oGroup=Nothing



Mon, 24 Nov 2003 10:23:11 GMT  
 Adding a Domain Global group to a machine local group in Windows 2000
Try this for the computer name:

dim objNet
set objNet = createobject("wscript.network")
strLocalMachine = objNet.ComputerName
set objNet = nothing

Haven't played with Active Directory enough to help you on the other issue.

--

Brainbench MVP for Visual Basic
http://www.brainbench.com


Quote:
> I have written the following code to add a user to the from the domain to
a
> local group on a workstation.  I would like to make two changes to the
> script.  First, I would like to adapt the code to add a domain global
group
> to a local group on the machine.  Second, when setting the strLocalMachine
> string I would like to pull the local computer name system variable from
the
> workstation into this so that it is dynamic.  Any help is appreciated.

> strPDC="CHESVA14"
> strLocalMachine="lt00972"
> strUser="user"
> strGroup="power users"
> Set oDomain = GetObject("WinNT://" & strLocalMachine)
> Set oGroup = oDomain.GetObject("Group", strGroup)
> oGroup.Add ("WinNT://" & strPDC & "/" & strUser)
> Set oDomain=Nothing
> Set oGroup=Nothing



Mon, 24 Nov 2003 12:22:43 GMT  
 Adding a Domain Global group to a machine local group in Windows 2000
Works great thanks for the code!  Now that this is working I have created a
problem.  When the script runs a second time against the machine it pops up
a message stating that the user already exists in the group.  I know how
check membership of a domain group but not on a local group.  Thanks


Quote:
> Try this for the computer name:

> dim objNet
> set objNet = createobject("wscript.network")
> strLocalMachine = objNet.ComputerName
> set objNet = nothing

> Haven't played with Active Directory enough to help you on the other
issue.

> --

> Brainbench MVP for Visual Basic
> http://www.brainbench.com



> > I have written the following code to add a user to the from the domain
to
> a
> > local group on a workstation.  I would like to make two changes to the
> > script.  First, I would like to adapt the code to add a domain global
> group
> > to a local group on the machine.  Second, when setting the
strLocalMachine
> > string I would like to pull the local computer name system variable from
> the
> > workstation into this so that it is dynamic.  Any help is appreciated.

> > strPDC="CHESVA14"
> > strLocalMachine="lt00972"
> > strUser="user"
> > strGroup="power users"
> > Set oDomain = GetObject("WinNT://" & strLocalMachine)
> > Set oGroup = oDomain.GetObject("Group", strGroup)
> > oGroup.Add ("WinNT://" & strPDC & "/" & strUser)
> > Set oDomain=Nothing
> > Set oGroup=Nothing



Tue, 25 Nov 2003 08:11:29 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How do I add a domain global-groups in a member-server local group

2. Add Global group to Local Group

3. help Adding a Domain group to a Local Group

4. Add a domain group to local machine

5. Add domain group to local group

6. Adding domain groups to gthe local administrator group

7. Adding a domain group to local administrators group

8. Add a domain group to local machine

9. Determine global group in local group

10. How to find local groups for a global group

11. ADSI Global Groups / Local Groups

12. Adding Global into Local Groups

 

 
Powered by phpBB® Forum Software