Solved

Need script to generate a list of all of the groups in AD with the word Intranet in it

Posted on 2011-02-18
3
283 Views
Last Modified: 2012-06-27

I am having a lot of trouble creating a script that works that lists all of the groups in our domain with the word Intranet in it.

Anyone have a sample script or can create a script that will do this?
0
Comment
Question by:wrkstat
3 Comments
 
LVL 57

Accepted Solution

by:
Mike Kline earned 250 total points
ID: 34927300
You can use a tool like adfind  http://www.joeware.net/freetools/tools/adfind/index.htm

adfind -default -f "&(objectcategory=group)(name=*intranet*)"  name samacountname

Let me know how that works.

Thanks

Mike
0
 
LVL 14

Expert Comment

by:athomsfere
ID: 34927333
Does it have to be VBScript?

I can give you a one-liner Powershell script with the Quest Active directory tools cmdlets.

Get-QADGroup -Name *intranet* | Format-Table Name, email, DN

That will find all groups (Distro and security actually) and return the name, email and DN.
0
 
LVL 12

Expert Comment

by:prashanthd
ID: 34927911
You can also try this Vbscript

On Error Resume Next
Dim objConnection, objCommand, objRootDSE, strDNSDomain
Dim strFilter, strQuery, objRecordSet, gt
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
'Get domain
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
'Define the filter elements
strFilter = "(&(objectCategory=group)(name=*intranet*)"
'List all attributes you will require
strAttributes = "distinguishedName,sAMAccountName"
'compose query
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 99999
objCommand.Properties("Timeout") = 300
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    strDN = objRecordSet.Fields("distinguishedName")
    strSA = objRecordSet.Fields("sAMAccountName")
    Wscript.Echo strSA
    objRecordSet.MoveNext
Loop
' Clean up.
objConnection.Close
Set objConnection = Nothing
Set objCommand = Nothing
Set objRootDSE = Nothing
Set objRecordSet = Nothing
0

Join & Write a Comment

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now