Skip to content

Daniels Tagesmeldungen

Kleine IT-Episoden, der Diabetes & das wahre Leben

  • Startseite
  • About me…
    • Lebenslauf
    • Weiterbildung
  • Diabetes melitus
    • Diabetes melitus – Definition/Typen
    • Diabetes melitus – Podcasts
    • Diabetes Typ-2 – Erläuterung
    • Medikament – Forxiga (Dapagliflozin)
    • Medikament – Eylea (Aflibercept)
    • Medikament – Lucentis (Ranibizumab )
    • Medikament – Metformin
  • Disclaimer
  • Toggle search form

Alle Domänengruppen inkl. Mitglieder in HTML auflisten

Posted on 25. Juni 201225. Juni 2012 By Daniel Lensing 2 Kommentare zu Alle Domänengruppen inkl. Mitglieder in HTML auflisten

Aufgrund von umfangreicher Benutzerlöschungen habe ich einen Report erstellen wollen, welcher Benutzer in welcher Gruppe als Mitglied zum aktuellen Zeitpunkt eingebunden ist.

Dafür habe ich ein sehr angenehmes VBS-Skript gefunden, welches ich minimal für die Abfrage des Managers erweitert habe. Der Report selber wird als HTML-Datei angelegt.

' DocumentGroups.vbs
' VBScript program to document all groups in Active Directory.
' Outputs group name, type of group, all members, and types of member.
' Lists all groups that are members, but does not list the nested group
' membership.
'----------------------------------------------------------------------
' Copyright (c) 2002 Richard L. Mueller
' Hilltop Lab web site - http://www.rlmueller.net
' Version 1.0 - November 10, 2002
' Version 1.1 - February 19, 2003 - Standardize Hungarian notation.
' Version 1.2 - March 11, 2003 - Remove SearchScope property.
 
' *** MODIFIED March 13, 2006 - Added HTML File Out, Addtional Group/User Properties
'
' This script is designed to be run at a command prompt, using the
' Cscript host. The output can be redirected to a text file.
' For example:
' cscript //nologo DocumentGroups.vbs > groups.txt
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided that
' you agree that the copyright owner above has no warranty,obligations,
' or liability for such use.
'
' Version 1.3 - June 25, 2012 - Added attribute "managedby" by Daniel Lensing
 
Option Explicit
 
Dim objConnection, objCommand, objRootDSE, strDNSDomain, strQuery
Dim objRecordSet, strDN, objGroup
Dim FileSystem, oFile
' Open Text File for Output
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set oFile = FileSystem.CreateTextFile("GroupMemebrshipNew.html", True)
 
oFile.writeLine "<HTML><HEAD><TITLE>Group Membership for MyDomain.com</TITLE><HEAD><BODY>"
oFile.writeLine "<h4><TABLE width=100% border=0 padding=0 cellspacing=0 valign=top>"
 
 
' Use ADO to search Active Directory.
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
 
' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
 
' Search for all groups, return the Distinguished Name of each.
strQuery = "<LDAP://" & strDNSDomain _
& ">;(objectClass=group);distinguishedName;subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
 
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
Wscript.Echo "No groups found"
objConnection.Close
Set objRootDSE = Nothing
Set objConnection = Nothing
Set objCommand = Nothing
Set objRecordSet = Nothing
Wscript.Quit
End If
 
' Enumerate all groups, bind to each, and document group members.
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName")
Set objGroup = GetObject("LDAP://" & strDN)
 
' OUTPUT
oFile.writeLine "<TR>"
oFile.writeLine "<TD width=20% valign=top bgcolor=black><font color=white><strong><u>" & "Group Name:" &_
"</u></strong></font></TD><TD width=80% valign=top><strong>" &_
objGroup.SAMaccountName & "</strong></TD>"
oFile.writeLine "</TR><TR>"
oFile.writeLine "<TD valign=top bgcolor=black><font color=white><strong><u>" & "Distinguished Name:" &_
"</u></strong></font></TD><TD valign=top><strong>" &_
objGroup.distinguishedName & "</strong></TD>"
oFile.writeLine "</TR><TR>"
oFile.writeLine "<TD valign=top bgcolor=black><font color=white><strong><u>" & "Description:" &_
"</u></strong></font></TD><TD valign=top><strong>" &_
objGroup.description & "</strong></TD>"
oFile.writeLine "</TR><TR>"
oFile.writeLine "<TD valign=top bgcolor=black><font color=white><strong><u>" & "Manager:" &_
"</u></strong></font></TD><TD valign=top><strong>" &_
objGroup.managedby & "</strong></TD>"
oFile.writeLine "</TR><TR>"
oFile.writeLine "<TD valign=top bgcolor=black><font color=white><strong><u>" & "Type:" & "</u></strong></font></TD><TD valign=top><strong>" & GetType(objGroup.groupType) & "</strong></TD>"
oFile.writeLine "</TR>"
 
oFile.writeLine "<TR><TD valign=top bgcolor=black><font color=white><strong><u>Members:</font></TD><TD align=left valign=top>"
oFile.writeLine "<TABLE width=70% border=0 cellspacing=0 cellpadding=0>"
oFile.writeLine "<Tr>"
oFile.writeLine " <TD valign=top><strong><u> Name </u></strong></TD>"
oFile.writeLine " <TD valign=top><strong><u> Account </u></strong></TD>"
oFile.writeLine " <TD valign=top><strong><u> Type </u></strong></TD>"
oFile.writeLine "</Tr>"
Call GetMembers(objGroup)
oFile.writeLine "</TABLE>"
 
oFile.writeLine "</TD></TR>"
 
oFile.writeLine "<TR><TD COLSPAN=2><hr width=90%></TD></TR>"
 
 
objRecordSet.MoveNext
 
Loop
oFile.writeLine "</TABLE></BODY></HTML>"
 
msgBox "Done !!!"
 
' Clean up.
objConnection.Close
Set objRootDSE = Nothing
Set objGroup = Nothing
Set objConnection = Nothing
Set objCommand = Nothing
Set objRecordSet = Nothing
 
Function GetType(intType)
' Function to determine group type from the GroupType attribute.
If (intType And &h01) <> 0 Then
GetType = "Built-in"
ElseIf (intType And &h02) <> 0 Then
GetType = "Global"
ElseIf (intType And &h04) <> 0 Then
GetType = "Local"
ElseIf (intType And &h08) <> 0 Then
GetType = "Universal"
End If
If (intType And &h80000000) <> 0 Then
GetType = GetType & "/Security"
Else
GetType = GetType & "/Distribution"
End If
End Function
 
Sub GetMembers(objADObject)
' Subroutine to document group membership.
' Members can be users or groups.
Dim objMember, strType
For Each objMember In objADObject.Members
If UCase(Left(objMember.objectCategory, 8)) = "CN=GROUP" Then
strType = "Group"
Else
strType = "User"
End If
 
' OUTPUT
 
oFile.writeLine "<TR>"
oFile.writeLine "<TD valign=top>" & objMember.displayName & _
"</TD><TD valign=top>" & objMember.SAMaccountName & _
"</TD><TD valign=top>" & strType & "</TD>"
oFile.writeLine "</TR>"
' Wscript.Echo " Member: " & objMember.sAMAccountName & " (" & strType & ")"
Next
Set objMember = Nothing
End Sub
VBS

Beitrags-Navigation

Previous Post: Skript: Server-Erstkonfiguration per Powershell
Next Post: Remedy: Berichtsexport direkt in Excel

Comments (2) on “Alle Domänengruppen inkl. Mitglieder in HTML auflisten”

  1. mallerSt sagt:
    28. Juni 2012 um 16:40 Uhr

    Das habe ich nicht ganz verstanden oder leider funktioniert das bei mir nicht richtig. Für was steht denn das oFile.writeLine „“ ?

  2. Daniel Lensing sagt:
    28. Juni 2012 um 21:01 Uhr

    Der Befehl „oFile.writeLine“ wird verwendet, um den Unhalt in die HTML-Datei zu schreiben.
    Das Skript wurde auch mit dem Befehlssatz „cscript dateiname.vbs“ aufgeführt?!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Daniel Lensing

Ich betreibe diesen Blog, bei dem ich meine Erfahrungen aus der IT & dem Berufsalltag sowie dem Wahnsinn des Lebens mit Höhen und Tiefen. Darunter meine „Erlebnisreise“ zum Planeten „Diabetes mellitus Typ-2“.

Translate:

Follow us

Kategorien

  • Client (229)
    • Android (7)
    • Fedora (Linux) (5)
    • iOS (5)
    • Mac OS X (5)
    • Peripherie (5)
    • Ubuntu (Linux) (8)
    • Windows 10 (54)
    • Windows 11 (15)
    • Windows 7 (100)
    • Windows 8 (36)
    • Windows 8.1 (28)
    • Windows Mobile (2)
    • Windows Vista (65)
    • Windows XP (21)
  • Cloud (15)
    • Amazon AWS (1)
    • Microsoft Azure (7)
    • Office 365 (9)
  • Fortbewegung (55)
    • Auto (17)
    • Bahn (17)
    • Beinarbeit (5)
    • Flugzeug (3)
    • Zweirad (14)
  • IT-Nachrichten (37)
  • Leben Beruf und Gesundheit (190)
    • #t2dhero (46)
    • Arbeitszimmer (26)
    • Audio (19)
    • Film / Kino (7)
    • Gedanken (75)
    • Gesundheit (29)
    • Internet (4)
    • Lebensmittel & Essen (21)
    • Lesestoff (18)
    • Sport (10)
    • Veranstaltung (3)
  • Lehren & Lernen (48)
    • Forschung (1)
    • Konferenzen (3)
    • Präsentation (3)
    • Zertifizierung (42)
  • Programme (318)
    • Android-Apps (27)
    • Eigene Tools (11)
    • iOS-Apps (6)
    • Office (85)
    • Patchday+Updates (71)
    • Software (145)
    • Spiele (3)
    • Windows Phone-Apps (2)
  • Programmierung (88)
    • AutoIT (1)
    • KiXtart (1)
    • PHP (3)
    • Power Automate (1)
    • Powershell (57)
    • VB.NET (8)
    • VBA (10)
    • VBS (10)
  • Server (156)
    • Citrix XenServer (2)
    • Exchange Server (26)
    • Lync Server (1)
    • System Center (4)
    • Ubuntu Server (2)
    • Windows Home Server (2)
    • Windows Server (91)
    • Windows Server 2012 (45)
    • Windows Server 2016 (15)
    • Windows Server 2019 (15)
    • Windows Server 2022 (12)
    • Windows Server 2025 (5)
  • Telekommunikation (38)
    • Festnetz (3)
    • Internet (13)
    • Mobilfunk (23)
  • Verkauf & Verlosung (1)
  • Web-Installationen (36)
    • Joomla (4)
    • Mastodon (1)
    • MediaWiki (9)
    • phpMyAdmin (2)
    • Piwik (4)
    • Wordpress (20)
Mastodon

Copyright © 2025 Daniels Tagesmeldungen.

Powered by PressBook WordPress theme