Option Explicit Dim strUserName, strUserSid, intError If Wscript.Arguments.Count = 0 Then 'Script is being called after the machine has been joined to the new domain 'Add custom code here WScript.Quit End If 'Profwiz will pass two parameters to the script - the new domain user account name and the user SID If Wscript.Arguments.Count = 2 Then strUserName = Wscript.Arguments(0) strUserSid = Wscript.Arguments(1) 'In this example we pass the user SID to a function which adds the user to the Administrators group intError = AddSidToGroup(strUserSid, "Administrators") If not intError=0 Then Err.Raise intError End If End If 'Returns 0 if successful, or an error number Function AddSidToGroup(strSID, strGroup) Dim objUser, objGroup Const ERR_ALREADY_MEMBER = &h80070562 On Error Resume Next Set objUser=GetObject("WinNT://" & strSID) If Err Then AddSidToGroup = Err.number Exit Function End If Set objGroup=GetObject("WinNT://./" & strGroup & ",group") If Err Then AddSidToGroup = Err.number Exit Function End If objGroup.Add objUser.ADsPath If Err Then If Err.Number = ERR_ALREADY_MEMBER Then AddSidToGroup = 0 Else AddSidToGroup = Err.number End If Else AddSidToGroup = 0 End If End Function