Solved

Computer Names in OU

Posted on 2015-02-03
3
75 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 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 84

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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Set OWA language and time zone in Exchange for individuals, all users or per database.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
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ā€¦

733 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