kaokulk
01-14-2003, 01:03 PM
I am starting to work on Windows 2000 scripts for the first time... I have this script, but it tells me that everyone is in every group (they are not). In fact, no person is in all three groups.
Also, none of the WScript.Echo's that are in the function display.
Any ideas where my mistake is?
Dim oNet
Dim oUser
set oNet = CreateObject("WScript.Network")
Set oUser = GetObject("WinNT://" & oNet.UserDomain & "/" & oNet.UserName)
WScript.Echo oUser.FullName
If IsGrpMember("_!Administration Staff") Then
WScript.Echo "Is a member of Admin"
Else
WScript.Echo "Is NOT a member of Admin"
End If
If IsGrpMember("_!Systems Staff") Then
WScript.Echo "Is a member of Systems"
Else
WScript.Echo "Is NOT a member of Systems"
End If
If IsGrpMember("_!Collections Staff") Then
WScript.Echo "Is a member of Collections"
Else
WScript.Echo "Is NOT a member of Collections"
End If
WScript.Quit
Function IsGrpMember (ByVal Group)
WScript.Echo "Hiya"
on error resume next
For Each grp in objUser.Groups
WScript.Echo 'grp.Name'
if grp.Name = Group then
IsGrpMember = True
Exit Function
end if
Next
IsGrpMember = False
End Function
Also, none of the WScript.Echo's that are in the function display.
Any ideas where my mistake is?
Dim oNet
Dim oUser
set oNet = CreateObject("WScript.Network")
Set oUser = GetObject("WinNT://" & oNet.UserDomain & "/" & oNet.UserName)
WScript.Echo oUser.FullName
If IsGrpMember("_!Administration Staff") Then
WScript.Echo "Is a member of Admin"
Else
WScript.Echo "Is NOT a member of Admin"
End If
If IsGrpMember("_!Systems Staff") Then
WScript.Echo "Is a member of Systems"
Else
WScript.Echo "Is NOT a member of Systems"
End If
If IsGrpMember("_!Collections Staff") Then
WScript.Echo "Is a member of Collections"
Else
WScript.Echo "Is NOT a member of Collections"
End If
WScript.Quit
Function IsGrpMember (ByVal Group)
WScript.Echo "Hiya"
on error resume next
For Each grp in objUser.Groups
WScript.Echo 'grp.Name'
if grp.Name = Group then
IsGrpMember = True
Exit Function
end if
Next
IsGrpMember = False
End Function