Solved

Computer Names in OU

Posted on 2015-02-03
3
69 Views
Last Modified: 2015-02-03
I am trying to get a list of computer names that are in a specific OU. There has to be a way of getting that to happen in Powershell. Anyone done this before?
0
Comment
Question by:stakor
3 Comments
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
Comment Utility
You just have to use the -searchbase parameter of Get-ADComputer with the distinguishedname of the OU.
Get-ADComputer -filter * -searchbase "OU=someOU,DC=domain,DC=com" | Select name

Open in new window

If you like you can also use the -searchscope parameter (set to "OneLevel") to limit the query so that it doesn't search child OUs.
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
Assuming a DC running W2k8R2 or later:
 Import-Module ActiveDirectory
Get-ADComputer -Filter * -SearchBase "OU=SomeDeeperOU,OU=SomeOU,DC=some,DC=domain,DC=local"

Open in new window

0
 
LVL 12

Expert Comment

by:FarWest
Comment Utility
check this
$ou = "OU=Workstations,OU=MyOU,DC=Fabrikam,DC=com"

$Computers = Get-ADComputer -Filter '*' -SearchBase $ou

$Computers | Foreach { $_.DNSHostName } | Out-File -Filepath "output.txt"

Open in new window


please note you have to import ActiveDirectory PowerShell Module
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will help you understand what HashTables are and how to use them in PowerShell.
A procedure for exporting installed hotfix details of remote computers using powershell
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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