• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

Search AD Containers and OUs

I need a script that can search of user groups that have no memberships.
The search can be done not only on the OU but also on the AD containers that are not an OU.

Thanks
0
jskfan
Asked:
jskfan
  • 6
  • 2
3 Solutions
 
jskfanAuthor Commented:
That's rich of info.

Could you please just paste here the script that can get the result I am looking for?

thanks
0
 
JBond2010Commented:
This link here that I have provided should do the trick and it will output the information in a excel sheet. There is an explaination of what the script does, so make sure to read this.

http://gallery.technet.microsoft.com/scriptcenter/d5c6b119-0337-4b5d-93f3-c409c6cf7a45

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
Mike KlineCommented:
Take a look at this question I helped with

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24719704.html

I used adfind for my method (much less typing) there are also vbscript examples there too.

Thanks

Mike
0
 
jskfanAuthor Commented:
it sounds like I will have to scroll all over the spreadsheet and see which group doesn't have an x , to tell if it's empty.
I got a script few days ago that worked 95% for me. Why 95 %? because
 -a it retrieved some user groups that have members in them
- b it works only for OUs , if I run the script agains a container which is not an OU, it doesn't get anything or it throws an error.

0
 
jskfanAuthor Commented:
it was still a very helpful script...

I need similar script but that can run also against the AD containers that are not OUs.
0
 
jskfanAuthor Commented:
On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT Name,Member FROM 'LDAP://dc=rustice,dc=local' WHERE objectCategory='group'"
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    If isNull(objRecordSet.Fields("Member").Value) Then
          Wscript.Echo objRecordSet.Fields("Name").Value
    End If
    objRecordSet.MoveNext
Loop
0
 
jskfanAuthor Commented:
All I needed was to replace OU with CN ....

0
 
jskfanAuthor Commented:
thanks
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now