[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Computer Names in OU

Posted on 2015-02-03
3
Medium Priority
?
85 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 41

Accepted Solution

by:
footech earned 2000 total points
ID: 40586079
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 85

Expert Comment

by:oBdA
ID: 40586081
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
ID: 40586082
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

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

Question has a verified solution.

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

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

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