Good morning all,
I need help to add the following additions to a script.
1) Recursive queries (e.g if a group is contained in a group it doesn’t go into that and retrieve all the members)
2) Instead of looking for the AllowLogon right look for memberOf the Terminal Services group
The goal is to show all the active accounts who are members of the All Networked Staff group. Of these who is can log into the terminal server and those who can not. This differentiates the shared mailbox accounts from the hosted desktop users.
' Saves a list of users in a specific group to a text file
' The list contains usernames and TRUE or FALSE if the account is disabled
' A sum total appears at the end of the file
'
Option Explicit
'
' Variable Declarations
'
Const ForReading = 1,ForWriting = 2,ForAppending = 8
Dim strOutputFile, strDomainName, strGroupName
Dim intActive, intDisabled
Dim objFSO, objTextFile, objShell
Dim objGroup, objMember
'
' Variable Definitions
'
Set objShell = WScript.CreateObject("Wscript.Shell")
strDomainName = objShell.ExpandEnvironmentStrings( "%USERDOMAIN%" )
strGroupName = inputbox("This script will export a list of users from the " & strDomainName & " domain who are members of the group specified below.","Target Group","")
intActive = 0
intDisabled = 0
'
' Query AD for Group object
'
Set objGroup = GetObject("WinNT://" & strDomainName & "/" & strGroupName)
'
' Create text file object for output and write the first few lines
'
strOutputFile = "Active Users.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strOutputFile,ForWriting, True)
objTextFile.writeline("Domain: " & strDomainName & " Group: " & strGroupName)
objTextFile.writeline("")
objTextFile.writeline("Name, Disabled")
'
' Iterate over member list and write out to file
'
For Each objMember In objGroup.Members
objTextFile.writeline (objMember.Name & ", " & objMember.AccountDisabled)
If objMember.AccountDisabled = FALSE Then
intActive = intActive + 1
Else
intDisabled = intDisabled + 1
End If
Next
'
' Write out the sum totals
'
objTextFile.writeline ("")
objTextFile.writeline ("Active: " & intActive )
objTextFile.writeline ("Disabled: " & intDisabled )
objTextFile.writeline ("Total: " & intActive + intDisabled)
objTextFile.close
wscript.echo "All Done"
'
Thanks in advance for you help, it's greatly appreciated
J