Re: Add Computer to a group!

Tech-Archive recommends: Fix windows errors by optimizing your registry



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



.



Relevant Pages

  • Re: Logon script - function array and select case not working
    ... I like to use Dictionary Objects when I must bind to many objects, ... ' Check membership in Group A. First bind to the group object. ... I am trying to rewrite my logon scripts which are all in vbscript. ... objTSout.writeline retrv ...
    (microsoft.public.scripting.vbscript)
  • Re: Enumeration of AD
    ... Here is an example VBScript program that documents all user Distinguished ... You can also use tools like csvde and ldifde, which should be on your DC's. ... And you can use Joe Richards' free ADFind utility to document just about ... Microsoft MVP Scripting and ADSI ...
    (microsoft.public.windows.server.active_directory)
  • Re: Active Directory User Membership limit
    ... I was hoping a command line tool like adfind or dsquery could get this ... VBScript program dumps out the Distinguished Names of all users in the ...     ' Retrieve values. ... security group membership (including the "primary" group and membership ...
    (microsoft.public.windows.server.active_directory)
  • Re: Enumeration of AD
    ... Here is an example VBScript program that documents all user Distinguished ... And you can use Joe Richards' free ADFind utility to document just about ... You need special tools to document GPO's. ... Microsoft MVP Scripting and ADSI ...
    (microsoft.public.windows.server.active_directory)
  • Re: Load batch files based on groups
    ... ' Bind to each group object. ... Set WshShell = CreateObject ... ' Check for membership in second group. ... I bind to the user object because it seemed to make things easier. ...
    (microsoft.public.scripting.vbscript)