views:

632

answers:

2

I tried the following after creating the new group:

$adminGroup = [ADSI]"WinNT://./Administrators"
$group =[ADSI]"WinNT://./Test1"
#$adminGroup.Add($group) - This does not work

Any idea what is missing?

+1  A: 

Are you really adding stuff on your local machine?? Otherwise, I'd strongly recommend using the LDAP provider instead of WinNT:// - that's provided just for local machine handling, and backward compatibility, really.

If you must use WinNT:// - if I remember correctly, typically you had to provide the type of object you were dealing with. Not sure if that translates to the PowerShell cmdlets as well - but you could always try!

$adminGroup = [ADSI]"WinNT://./Administrators,group"
$group =[ADSI]"WinNT://./Test1,group"

And I vaguely remember there were issues with trying to nest groups with the WinNT provider, I think. I know LDAP:// can do it no problems - not sure if it ever worked on WinNT:// though.... (it's been too long).

Marc

marc_s
+2  A: 

Not sure why it isn't working with the period, but it works fine if you use the computername variable

$group = [ADSI]"WinNT://$env:computername/Administrators,group"
$group.add("WinNT://$env:computername/Test1")
Mike Pfeiffer