Page 1 of 1 1
Topic Options
#176961 - 2007-06-13 09:08 PM adding computer in groups
sealover Offline
Fresh Scripter

Registered: 2005-05-09
Posts: 12
Hi all,

at first, sorry for my bad english and if the question already asked.

I'm trying to make a script that add computer to ad group (security, distribution, global).

All the example I found are for user. So is there a way to do what i want?

Top
#176962 - 2007-06-13 10:48 PM Re: adding computer in groups [Re: sealover]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Get NETDOM from Microsoft and then script what you want with it.

There are some UDFs here but not sure they're as complete as you need for what you're wanting to do but they might be. Search in the UDF forum.

Top
#176966 - 2007-06-14 10:14 AM Re: adding computer in groups [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
 Originally Posted By: NTDOC
Get NETDOM from Microsoft and then script what you want with it.

There are some UDFs here but not sure they're as complete as you need for what you're wanting to do but they might be. Search in the UDF forum.


Would you stop suggesting NETDOM :P
Try here: ADSI Computer Essentials

Top
#176967 - 2007-06-14 11:10 AM Re: adding computer in groups [Re: Arend_]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
 Originally Posted By: apronk

Would you stop suggesting NETDOM :P
Try here: ADSI Computer Essentials


Nope, LOL

NETDOM has gone through extensive testing and has a hundred more options/features then your script ;\)

Now maybe some day you'll get time to match NETDOM in script format so I'll still have to at least suggest it.

For quickie your code should work though I suppose.

Top
#176971 - 2007-06-14 11:38 AM Re: adding computer in groups [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
I'm not comparing NetDom to my scripts \:\)
Just saying that anything NETDOM does can be done trough LDAP/WinNT Scripting.

Top
#176972 - 2007-06-14 12:55 PM Re: adding computer in groups [Re: Arend_]
sealover Offline
Fresh Scripter

Registered: 2005-05-09
Posts: 12
so at first thanks for your answer...

Can I consider that a workstation is like a user? I want to say that I find a lot of add user group but never a add computer group?

Top
#176981 - 2007-06-14 03:12 PM Re: adding computer in groups [Re: sealover]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
No, there is a distinct difference between a user and a computer account.
There is no Computer Group, nor can one be created, a computer account cannot be a member of a group.

Top
#176982 - 2007-06-14 03:18 PM Re: adding computer in groups [Re: Arend_]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: apronk
...a computer account cannot be a member of a group.
Huh?

I create groups for computers and add computers as members.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176985 - 2007-06-14 03:30 PM Re: adding computer in groups [Re: Les]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
 Originally Posted By: Les
 Originally Posted By: apronk
...a computer account cannot be a member of a group.
Huh?

I create groups for computers and add computers as members.


I stand corrected, I never needed to \:\)
Just checked if it could.

One of the downsides of only scripting your AD \:\)

Top
#177589 - 2007-07-05 09:43 AM Re: adding computer in groups [Re: Arend_]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Erhm, there's two kinds of accounts - user and computer with different things in 'em of course - and then there's groups, that can contain accounts :). Shouldn't be a biggie to add a computer instead of user scriptwise.

Am I wrong?

 Code:
;accountname = computer or user
;groupname = name of group to add account to
$ldap = GetObject("LDAP://OU=SomeSubOU,OU=SomeOU,DC=SomeDomain,DC=SomeDomainExtention")
$ldap.Add("[accountname]","[groupname]")


Just 'translated' from vbs;
 Code:
$strDomain="Workgroup"
$strComp="jdoe"
$strGroupName ="Administrators"

$oDomain = GetObject("WinNT://" + $strDomain)
$oGroup = $oDomain.GetObject("Group", $strGroupName)
$oGroup.Add ("WinNT://" + $strDomain + "/" + $strComp)


Edited by Björn (2007-07-05 10:12 AM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#177591 - 2007-07-05 09:52 AM Re: adding computer in groups [Re: Björn]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Nope, works exactly the same as adding users to groups.
Top
#177592 - 2007-07-05 09:56 AM Re: adding computer in groups [Re: Arend_]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Think i 'fixed' my snippet, could you perhaps verify? ;\)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#181915 - 2007-10-25 12:07 AM Re: adding computer in groups [Re: Björn]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Does this work for anyone else?

 Code:
$strDomain="Workgroup"
$strComp="jdoe"
$strGroupName ="Administrators"

$oDomain = GetObject("WinNT://" + $strDomain)
$oGroup = $oDomain.GetObject("Group", $strGroupName)
$oGroup.Add ("WinNT://" + $strDomain + "/" + $strComp)
When I try to add a computer to a group I get this error:

 Quote:
0009] Encountered: COM exception error "Add" ((null) - (null)) [-2147352567/8002


I also get the same error when using the GroupAdd() udf.
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#182039 - 2007-10-29 01:52 PM Re: adding computer in groups [Re: brewdude6]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Can anyone verify this for me please?
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#182134 - 2007-10-31 05:23 PM Re: adding computer in groups [Re: brewdude6]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Is there anyone that could help me out here? I'm not able to add a computer to a domain group with the posted code. I'm not sure what would need to change or if it's even possible? Any ideas?
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#182139 - 2007-10-31 06:13 PM Re: adding computer in groups [Re: brewdude6]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well can't promise but if I get time today I'll try to test out some code for you.

What exactly are you trying to do?

Place a single computer into a Active Directory group?

Is the computer already a member of the Domain or you're adding it to the Domain as well?

Top
#182143 - 2007-10-31 06:50 PM Re: adding computer in groups [Re: NTDOC]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Thanks NTDOC...I plan on using islaptop() or a GPO wmi filter to determine if the current computer is a laptop and add the computer account to a domain group.

The computers are already members of the domain so I'm not trying to do anything other than the above.
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#182144 - 2007-10-31 06:52 PM Re: adding computer in groups [Re: NTDOC]
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
When You are working on AD objects using WinNT the names are NT4 names, so the name for a computer named JDOE will be JDOE$.
The code for Adding computer JDOE to a group would be:
 Code:
$strDomain="Workgroup"
$strComp="jdoe$$"
$strGroupName ="Administrators"

$oDomain = GetObject("WinNT://" + $strDomain)
$oGroup = $oDomain.GetObject("Group", $strGroupName)
$oGroup.Add ("WinNT://" + $strDomain + "/" + $strComp)

-Erik

Top
#182145 - 2007-10-31 06:56 PM Re: adding computer in groups [Re: kholm]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
That's IT! Thank you so much!
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.072 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org