Re: Add Computer to a group!
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 18 Dec 2007 11:00:52 -0600
If I understand, the VBScript program could be similar to:
===============
' Bind to the group object.
Set objGroup = GetObject("LDAP://cn=TestGroup,ou=West,dc=MyDomain,dc=com")
' Bind to the specific OU, using Distinguished Name:
Set objOU = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")
' Filter on computer objects in the OU.
objOU.Filter = Array("computer")
' Enumerate computer objects in the OU.
For Each objComputer In objOU
' Check membership.
If (objGroup.IsMember(objComputer.AdsPath) = False) Then
' Add the computer to the group.
objGroup.Add(objComputer.AdsPath)
End If
Next
==============
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
"Jeffery Hicks [MVP]" <jhicks@xxxxxxxxxx> wrote in message
news:1A989C08-E32F-4F9E-A9E9-43624BD425FC@xxxxxxxxxxxxxxxx
You should be able to substitute a computer name for the user name.
Although it might depend on the group type. Can you post the code you're
trying to use to add a group member?
--
Jeffery Hicks
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org
Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.
"Henrik" <Henrik@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:99F2C4DB-3001-4388-A96E-4A5149EFA6A1@xxxxxxxxxxxxxxxx
I'm looking for a script that will add all computers in a specific OU to
a
group. I intend to shedule the script to run every night so it would be
great
if it doesn't try to add computers that are already members of the group.
I have found scripts that does this but with users. I can?t seem to get
them
to work with computers though.
Anyone that can support me on this one?
Thanks,
Henrik
.
- References:
- Re: Add Computer to a group!
- From: Jeffery Hicks [MVP]
- Re: Add Computer to a group!
- Prev by Date: Re: Force password reset for administrator
- Next by Date: Read registry of logged user user during EXE run as other user
- Previous by thread: Re: Add Computer to a group!
- Next by thread: Re: Add Computer to a group!
- Index(es):
Relevant Pages
|