Question

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?

Was it helpful?

Solution

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")

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top