Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!
Option Explicit Sub OutputGroupMembership() Dim varGroups, varItem Dim wksOut As Worksheet Dim rngOut As Range Dim varMembers Dim lngIndex As Long Dim strMemberlist As String ' this is the worksheet where the list will go ' adjust as required Set wksOut = ActiveSheet With wksOut ' add titles .Range("A1").Value = "Group name" .Range("B1").Value = "Member ID" ' first output cell Set rngOut = .Range("A2") End With ' this is the list of groups you want to get the members for varGroups = Array("Group 1", "Group 2") For Each varItem In varGroups ' output group name With rngOut .Value = varItem .Font.Bold = True End With ' move down a row Set rngOut = rngOut.Offset(1) ' get member list ' returned as a comma separated list strMemberlist = GetGroupUsers(varItem) ' split list into an array varMembers = Split(strMemberlist, ",") ' loop and output member IDs For lngIndex = LBound(varMembers) To UBound(varMembers) rngOut.Offset(, 1).Value = varMembers(lngIndex) Set rngOut = rngOut.Offset(1) Next lngIndex Next varItem End Sub Function GetGroupUsers(ByVal strGroupName As String) As String Dim objGroup, objDomain, objMember Dim strMemberlist As String, strDomain As String On Error Resume Next Set objDomain = GetObject("LDAP://rootDse") strDomain = objDomain.Get("dnsHostName") Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroupName & ",group") For Each objMember In objGroup.Members strMemberlist = strMemberlist & "," & objMember.Name Next objMember ' strip off the leading comma GetGroupUsers = Mid$(strMemberlist, 2) End Function
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Login Script to pull users IP Phone from AD and then create a registry key in HKCU with that value||8||26|
|Bringing new domain controller online. Testing part||6||46|
|Force Windows clients to authenticate to a specific domain controller||21||54|
|Chocolatey with PowerShell is not working again||2||39|