Page 1 of 1 1
Topic Options
#157356 - 2006-02-16 10:23 PM Add Computer to Domain Group?
Limbo Offline
Lurker

Registered: 2006-02-16
Posts: 3
Hoping someone can answer this for me. I am trying to add a compter object to a group object in AD. I've got it working for users, but it's computers I really need it to work for.
I have a script to determine if a computer is a laptop or desktop. I then need these computers adding to an appropriate group so GPOs can be filtered against them.
Here is the code I got working for adding a user (pretty simple)
Code:
$Group=GetObject("WinNT://DomainName/TESTGROUP,group")
$User=GetObject("WinNT://DomainName/TestUserName,user")
$Group.Add($User.ADsPath)


However, when I try to use the following instead it doesn't work and I get the error "COM exception error "Add" ((null) - (null)) [-2147352567/80020009]"
Code:
$Group=GetObject("WinNT://DomainName/TESTGROUP,group")
$Comp=GetObject("WinNT://DomainName/TestCompName,computer")
$Group.Add($Comp.ADsPath)


Is it not possible to add a computer to a group using this method?
All I could find in searching was to add a user to a group.

Wanting to get it working while logged in as Domain Admin, then I'll try to set the security on a group to allow computers to add themselves.

Any help would be great, it's bugging the hell out of me

Top
#157357 - 2006-02-16 10:33 PM Re: Add Computer to Domain Group?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Try treating the computer as the user account it truly is. The computer's account ends in a "$" sign.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#157358 - 2006-02-16 11:05 PM Re: Add Computer to Domain Group?
Limbo Offline
Lurker

Registered: 2006-02-16
Posts: 3
Tried appending $ and $$, but no joy. I get this error instead for both:
COM exception error "Add" (Active Directory - An invalid directory pathname was passed) [-2147352567/80020009]

Top
#157359 - 2006-02-16 11:17 PM Re: Add Computer to Domain Group?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Comp=GetObject("WinNT://DomainName/TestCompName,computer")


did you treat it as a user?

Comp=GetObject("WinNT://DomainName/TestCompName$$,user")
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#157360 - 2006-02-16 11:27 PM Re: Add Computer to Domain Group?
Limbo Offline
Lurker

Registered: 2006-02-16
Posts: 3
Your a damn genius, that's what you are!!!
Top
#157361 - 2006-02-16 11:33 PM Re: Add Computer to Domain Group?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11616
Loc: CA
Just an OLD Codger

Howard's a great guy, just spends too much time on Disney Blast! site

Top
#157362 - 2006-02-19 08:03 AM Re: Add Computer to Domain Group?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I gave up on the Disney site. I am now a Xbox Halo2 junky...
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 1 1


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

Who's Online
0 registered and 289 anonymous users online.
Newest Members
Kelly001, MichaelK72, Janneman, standardbruker, maikoenig2001
17773 Registered Users

Generated in 0.048 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

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