Dump a list of all AD groups in a Domain, and their users


Copy the script between the red line.

=============================================================

‘VBScript to output to text file the members of all groups

On Error Resume Next

Set objArgs=wscript.Arguments

If objArgs(0)<>”-dn” Then

wscript.echo “Dumping group membership using full DN…”

Else

wscript.echo “Dumping group membership using only first CN part…”

End If

‘Stuff for creating output text file

Const OutputFile = “.\groupdump.txt”

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Wshshell = Wscript.CreateObject(“Wscript.Shell”)

Set Output = Fso.OpentextFile(OutputFile, 2, True)

Set ADSIRootDSE = GetObject(“LDAP://RootDSE”)

ADSINamingNC = ADSIRootDSE.Get(“rootDomainNamingContext”)

Set ADSIConnection = CreateObject(“ADODB.Connection”)

ADSIConnection.Provider = “ADsDSOObject”

ADSIConnection.Open “ADs Provider”

ADSIQueryText = “<LDAP://” & ADSINamingNC & “>;(&(objectCategory=group));name,distinguishedName;subtree”

Set ADSICommand = CreateObject(“ADODB.Command”)

Set ADSICommand.ActiveConnection = ADSIConnection

ADSICommand.CommandText = ADSIQueryText

ADSICommand.Properties(“Page Size”) = 100

ADSICommand.Properties(“Timeout”) = 60

ADSICommand.Properties(“searchscope”) = 2

ADSICommand.Properties(“Cache Results”) = False

Set ADSIResult = ADSICommand.Execute

Do While not ADSIResult.EOF

Output.WriteLine

Output.WriteLine

Output.WriteLine “Group: ” & ADSIResult.Fields(“name”).Value

Output.WriteLine “===============================================================”

Set GetDN = GetObject(“LDAP://” & ADSIResult.Fields(“distinguishedName”).Value)

strAllValues = GetDN.GetEx(“member”)

iGroupCount = 0

For each strValue in strAllValues

If Len(strValue) = 0 Then

Output.WriteLine “There are no members in this group.”

Else

iGroupCount = iGroupCount + 1

If objArgs(0)<>”-dn” Then

Output.WriteLine strValue

Else

Call Stripper(strValue)

Output.WriteLine tmp

End If

End If

Next

Output.WriteLine “Total members in group: ” & iGroupCount

Set strAllValues = Nothing

ADSIResult.MoveNext

Loop

Output.Close

wscript.echo “Operation has finished.”

Wscript.quit

Function Stripper(StripperString)

pos = InStr(1, StripperString, “cn=”, vbTextCompare)

If pos <> 0 Then

tmp = Mid(StripperString, pos + 3)

pos = InStr(tmp, “,”)

If pos <> 0 Then tmp = Mid(tmp, 1, pos – 1)

End If

End Function

=============================================================

Dump a list of all AD groups in a Domain, and their users

Script to list all Citrix published applications and the users/groups assigned to them


=============================================================

‘****************************************************************************

‘pubAppRpt.vbs

‘Description: Write to the cmd session a list of all published apps and the

‘             users and groups assigned to them.

‘Usage:       e.g. >cscript pubAppRpt.vbs

‘****************************************************************************

Dim mfFarm

Dim mfApp

Dim mfGrp

Dim mfUsr

Set mfFarm = CreateObject(“MetaFrameCOM.MetaFrameFarm”)

mfFarm.Initialize 1

For Each mfApp In mfFarm.Applications

mfApp.LoadData 1

WScript.Echo “Published Application – ” & mfApp.Appname

WScript.Echo ”    Groups”

For Each mfGrp In mfApp.Groups

WScript.Echo ”        ” & mfGrp.GroupName

Next

WScript.Echo

WScript.Echo ”    Users”

For Each mfUsr In mfApp.Users

WScript.Echo ”        ” & mfUsr.UserName

Next

WScript.Echo

Next

=============================================================

Script to list all Citrix published applications and the users/groups assigned to them

Script to list all Citrix servers in a farm


=============================================================

On Error Resume Next

Const wbemFlagReturnImmediately = &h10

Const wbemFlagForwardOnly = &h20

ctxServer = “.”

Set objWMIService = GetObject(“winmgmts:\\” & ctxServer & “\root\Citrix”)

Set colItems = objWMIService.ExecQuery(“SELECT * FROM Citrix_Server”, “WQL”, _

wbemFlagReturnImmediately + wbemFlagForwardOnly)

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

If objFSO.FileExists(“FarmServers.txt”) Then

objFSO.DeleteFile “FarmServers.txt”

End If

Set objOutput = objFSO.CreateTextFile(“FarmServers.txt”)

For Each objItem In colItems

objOutput.WriteBlankLines

objOutput.WriteLine “==========================================”

objOutput.WriteLine “Server Name: ” & objItem.ServerName

objOutput.WriteLine “==========================================”

objOutput.WriteLine “Domain: ” & objItem.Domain

objOutput.WriteLine “Farm Name: ” & objItem.FarmName

objOutput.WriteLine “IP Address: ” & objItem.IPAddress

objOutput.WriteLine “Logins Enabled: ” & objItem.LoginsEnabled

objOutput.WriteLine “Zone Name: ” & objItem.ZoneName

objOutput.WriteLine “Zone Ranking: ” & objItem.ZoneRanking

objOutput.WriteBlankLines(2)

Next

objOutput.Save

objOutput.Close

Set objShell = CreateObject(“WScript.Shell”)

objShell.Run “notepad.exe FarmServers.txt”

=============================================================

Script to list all Citrix servers in a farm