Hi,

I've searched the board and can find lots of adding users to groups, but not groups to groups...

I have some script to view the local users on a network pc, then I can select a domain user and add them in as a local admin. This works fine. However as soon as I add domain groups as well as users to the listview and then select an object to add to the local machine, the scripts bombs out. Here is the script to populate the list

Code:
$domain=@ldomain
$GroupObj=GetObject("WinNT://"+ @ldomain + "/Domain Users")
$domaingroups=GetObject("WinNT://"+@ldomain)
$LocalAdminTabPage.Textbox1.Text=@CRLF+"Retrieving Domain User & Group List from Active Directory"
For each $UserObj in $GroupObj.Members
$Userlist.Items.Add($UserObj.Name)
$Userlist.Sorted="True"
NEXT
For each $Group in $domaingroups
$Userlist.Items.Add($Group.Name)
NEXT



and here is the adding bit :

Code:
Function AddUser()

$usertoadd=$UserList.FocusedItem.SubItems(0).Text
$group.Add("WinNT://"+ @ldomain + "/" + $usertoadd)
If @Error
Messagebox("Could not add user to Local Admins","Error",16)
ELSE
$confirm=Messagebox($usertoadd+" added to local admins on "+$target+". Add another?","Account Added",4)
ENDIF
IF $Confirm<>6
Cancel()
CheckAdminButton_Click()
ELSE
CheckAdminButton_Click()
ENDIF
EndFunction



($group is defined further up in the script as getobject("WinNT://"+$target+"/Administrators"))

Basically, if the domain groups are not included in the list view, the script works, when they are the adding function bombs.

Any help gratefully received!

Thanks.