Solved

AD quarrying  tools

Posted on 2013-02-03
10
505 Views
Last Modified: 2013-03-08
Hi Guys,

I am looking for a tool to quarrying AD object ( computers ), we have different computer OU like Test OU , DEV OU  and PROD OU etc . Could anyone please provide me simple quarrying tools or script to get just OU members ( servers and workstation) . I would like to get the final result in CVS format .

Regards
J
0
Comment
Question by:Jey_P
10 Comments
 
LVL 10

Assisted Solution

by:Prashant Girennavar
Prashant Girennavar earned 250 total points
ID: 38849948
Below is the powershell script which will list out the ComputerName, OperatingSystem and the Object patch where it exists.

Import-Module ActiveDirectory
$k = Get-ADComputer -Filter * -SearchBase "DC=Contoso,Dc=Com" -Properties *
$list = @()
Foreach ($os in $k)
{
 If ($os.Operatingsystem -match "windows *")
 {
  $list +=$os | Select-Object -Property @{l='Servername';e={$_.Name}},@{l='Operatingsystem';e={$_.Operatingsystem}},@{l='Objectpath';e={$_.CanonicalName}}
  }

  }
$list | Export-Csv C:\Windows.csv -NoTypeInformation
  

Open in new window



You should modify the DN (DC=Constoso,DC=com) according to your needs.

Hope this helps.

Regards,

_Prashant_
0
 
LVL 20

Assisted Solution

by:agonza07
agonza07 earned 100 total points
ID: 38849949
Change the LDAP for each OU, and modify the output to your liking. You can also nest the code to output in a CVS format for all your OUs.


' List All Computer Accounts in Active Directory


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.CommandText = _
    "Select Name, Location from 'LDAP://OU=TestOU,DC=fabrikam,DC=com' " _
        & "Where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
    Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
    objRecordSet.MoveNext
Loop

Open in new window

0
 
LVL 5

Expert Comment

by:coraxal
ID: 38849969
Well, I'd definitely recommend Powershell...one of the main goals of Powershell is to help in the administration of Microsoft technologies such as AD. I'd also suggest using the Quest AD Powerhsell cmdlets (very handy) http://www.quest.com/powershell/activeroles-server.aspx

Here's a sample script to query specific OU objects:
# To query user objects in a specific OU. Selecting the Name, SamAccountName, and DN of the user object

Get-QADUser -SearchRoot "OU=Test,DC=mydomain,DC=local" -SizeLimit 0 |
Select-Object Name,SamAccount,DN |
Export-Csv "C:\Temp\users.csv" -NoType

 # To query computer objects in a specific OU. Selecting the Name, SamAccountName of the computer object

Get-QADComputer -SearchRoot "OU=Test,DC=mydomain,DC=local" -SizeLimit 0 |
Select-Object Name,SamAccount,DN |
Export-Csv "C:\Temp\computers.csv" -NoType

# If you rather not install the Quest Powershell tools, and if you have the Active Directory powershell module installed on Windows 2008 R2

Get-ADUser -Filter * -ResultSetSize $null -SearchBase "OU=Test,DC=mydomain,DC=local" | 
Select-Object Name,SamAccountName,DistinguishedName |
Export-Csv "C:\Temp\users.csv" -NoType

Get-ADComputer -Filter * -ResultSetSize $null -SearchBase "OU=Test,DC=mydomain,DC=local" | 
Select-Object Name,SamAccountName | 
Export-Csv "C:\temp\computers.csv" -NoType

Open in new window

0
 

Accepted Solution

by:
Jey_P earned 0 total points
ID: 38850024
Does anyone has a tools instated of Script?
0
 
LVL 39

Expert Comment

by:footech
ID: 38850121
To me it's a bit unclear what information you actually want in the .CSV.  Do you just want the computer name?  When you query an OU, do you want to include child OUs?  Do you need to be able to query your entire AD at once, or a single OU, or what?

You could even use Active Directory Users and Computers (ADUC) for this.  You can navigate to an OU and export a list of all objects it contains, or to be more specific, go to Saved Queries and make a new query for what ever criteria you want.  Pick an OU, include subtrees or not, limit it to computers or whatever.  Choose what columns you want (when you export it will include all the columns you've chosen).  And when you export you can choose tab delimited or comma delimited.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 23

Expert Comment

by:Nagendra Pratap Singh
ID: 38850775
You can use CSVDE tool or LDIFDE.
0
 
LVL 18

Expert Comment

by:Americom
ID: 38851686
I would use the above suggestion regarding Saved Queries from ADUC. You can select the whole domain to list all the computer object or simply select the OU you want to list all the objects etc. Give it a try first and you may not need any other tools if you just need to find out or sort out specific types of objects and export them to a file.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38855846
You may try this AD reporting tool and see if it works for you...
http://www.cjwdev.co.uk/Software/ADReportingTool/Info.html
0
 

Author Comment

by:Jey_P
ID: 38948258
Thanks everyone.
0
 

Author Closing Comment

by:Jey_P
ID: 38965389
Thanks everyone.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A brief introduction to what I consider to be the best editor for PowerShell.
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…

867 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

19 Experts available now in Live!

Get 1:1 Help Now