MadMike1272
IS-IT--Management
I am trying to convert a .vbs script I have to pull the local admins of a server into a Server management Windows Application in VB. Everything is fine except VB does not except the Array statement in a filter like VBScript does. (It flags array as a type not an expression) Anybody have an idea for a replacement that will accomplish the same goal?
Here is the line the VB doesnt like:
oComputer.Filter = Array("group")
Here is the full code:
strGroup = inputbox( "Please enter a group name", "Input" )
txtOut = strGroup & "memberlist.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(txtOut,ForWriting)
Set oWshNet = CreateObject("WScript.Network")
Set oComputer = GetObject("WinNT://" & strComputer & ",computer")
oComputer.Filter = Array("group")
For Each oGroup In oComputer
If ucase(oGroup.Name) = ucase(strGroup) then
objFile.WriteLine "Members of group " & oGroup.Name & ":"
For Each oAccount in oGroup.Members
strAdmin = mid(oAccount.ADsPath,9)
objFile.WriteLine strAdmin
Next
End If
Next
Thanks,
Mike Titus
Here is the line the VB doesnt like:
oComputer.Filter = Array("group")
Here is the full code:
strGroup = inputbox( "Please enter a group name", "Input" )
txtOut = strGroup & "memberlist.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(txtOut,ForWriting)
Set oWshNet = CreateObject("WScript.Network")
Set oComputer = GetObject("WinNT://" & strComputer & ",computer")
oComputer.Filter = Array("group")
For Each oGroup In oComputer
If ucase(oGroup.Name) = ucase(strGroup) then
objFile.WriteLine "Members of group " & oGroup.Name & ":"
For Each oAccount in oGroup.Members
strAdmin = mid(oAccount.ADsPath,9)
objFile.WriteLine strAdmin
Next
End If
Next
Thanks,
Mike Titus