It is likely a timing issue, as you expect.
I would recommend not using scripts but rather group policy preferences to manage local group memberships anyway.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Guys
I tried to add some local and domain group to local admins group via windows group policy -startup scripts, as below.
Set objGroup = GetObject("WinNT://"&strComputerName&"/Administrators,group")
Set objUser = GetObject("WinNT://"&strComputerName&"/BL_OSD,user")
Set objADGroup1 = GetObject ("WinNT://"&strDomain&"/PCAdmins,group")
Set objADGroup2 = GetObject ("WinNT://"&strDomain&"/Domain Admins,group")
If Not ObjGroup.IsMember(objUser.ADsPath) Then
objGroup.Add(objUser.ADsPath)
End If
If Not objADGroup1.IsMember(objADGroup1.ADsPath) Then
objGroup.Add(objADGroup1.ADsPath)
End If
If Not objADGroup2.IsMember(objADGroup2.ADsPath) Then
objGroup.Add(objADGroup2.ADsPath)
End If
Then i found that the local account "BL_OSD" added to the local admins group. However failed to add the domain group.
I added some err handling script ,like err.number after the
"Set objADGroup2 = GetObject ("WinNT://"&strDomain&"/Domain Admins,group")"
and found the error number was "-2147024843", i googled the error number ,seems it means the network path was not found.
But if i manually run the script after user login, everything works as expect.
So i wondering the problem maybe due to network was ready when the scripts running at startup or anything else?
Kindly need your help
Thanks
jacky
It is likely a timing issue, as you expect.
I would recommend not using scripts but rather group policy preferences to manage local group memberships anyway.