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