Hi,
Can someone give this the one over? Not sure what some of you guys use for distribution. Unfortunately we use Kace (opinion on this for different time, different forum) and when this is run as a stand alone vbscript it appears to be just fine. So I am thinking this darn Kace does not have the rights to run this. I can check that. I just want to see if the code could be cleaned up, even though it does appear fine outside of this Kace environment.
set WshShell = WScript.CreateObject("WScript.Shell")
Set wshNetwork = WScript.CreateObject("WScript.Network")
strUserDomain = wshNetwork.UserDomain
If strUserDomain = "ABC" Then
Set objLocalGroup = GetObject("WinNT://./Administrators")
Set objADGroupABC1 = GetObject("WinNT://abc/Tom")
Set objADGroupABC2 = GetObject("WinNT://abc/Jerry")
objLocalGroup.Add(objADGroupABC1.ADsPath)
objLocalGroup.Add(objADGroupABC2.ADsPath)
Set objLocalGroupABC = Nothing
Set objADGroupABC1 = Nothing
Set objADGroupABC2 = Nothing
ElseIf strUserDomain = "_XYZ" Then
Set objLocalGroup = GetObject("WinNT://./Administrators")
Set objADGroup_XYZ = GetObject("WinNT://_XYZ/Tom")
objLocalGroup.Add(objADGroup_XYZ.ADsPath)
Set objLocalGroup = Nothing
Set objADGroup_XYZ = Nothing
End If
Can someone give this the one over? Not sure what some of you guys use for distribution. Unfortunately we use Kace (opinion on this for different time, different forum) and when this is run as a stand alone vbscript it appears to be just fine. So I am thinking this darn Kace does not have the rights to run this. I can check that. I just want to see if the code could be cleaned up, even though it does appear fine outside of this Kace environment.
set WshShell = WScript.CreateObject("WScript.Shell")
Set wshNetwork = WScript.CreateObject("WScript.Network")
strUserDomain = wshNetwork.UserDomain
If strUserDomain = "ABC" Then
Set objLocalGroup = GetObject("WinNT://./Administrators")
Set objADGroupABC1 = GetObject("WinNT://abc/Tom")
Set objADGroupABC2 = GetObject("WinNT://abc/Jerry")
objLocalGroup.Add(objADGroupABC1.ADsPath)
objLocalGroup.Add(objADGroupABC2.ADsPath)
Set objLocalGroupABC = Nothing
Set objADGroupABC1 = Nothing
Set objADGroupABC2 = Nothing
ElseIf strUserDomain = "_XYZ" Then
Set objLocalGroup = GetObject("WinNT://./Administrators")
Set objADGroup_XYZ = GetObject("WinNT://_XYZ/Tom")
objLocalGroup.Add(objADGroup_XYZ.ADsPath)
Set objLocalGroup = Nothing
Set objADGroup_XYZ = Nothing
End If