get-adcomputer to list objects in a specific OU

Dear All,

I have the followiing structure in my AD, see attached file.
I need to use get-adcomputer -searchbase .... to list all computers in the OU computers only. I dont want to have Servers.
How I can achieve that?

Thks
Capture.JPG
celmajjAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MaheshArchitectCommented:
Get-ADComputer -Filter {OperatingSystem -NotLike "*server*"} -Property * -Searchbase "ou=test,dc=domain,dc=,com"| Select Name,OperatingSystem,OperatingSystemServicePack | Export-csv C:\computer.csv -NoTypeInformation
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Naveen SharmaCommented:
You can try the below script to get a list of all computers from a certain OU

Get-ADComputer -Filter * -SearchBase "OU=TestOU,DC=TestDomain,DC=com" -Properties *  |
 Select -Property Name,DNSHostName,LastLogonDate

For more information, please refer to the article.

http://www.morgantechspace.com/2016/03/get-all-computers-from-ou-in-ad-using-powershell.html

Hope it helps
0
oBdACommented:
By pulling the OUs named "Computers" first, and then pulling all computers in there.
Get-ADOrganizationalUnit -Filter {Name -eq 'Computers'} |
	ForEach-Object {Get-ADComputer -Filter * -SearchBase $_.DistinguishedName} |
	Select-Object -Property Name, Enabled, DistinguishedName |
	Sort-Object DistinguishedName |
	Export-Csv -NoTypeInformation -Path C:\Temp\ADComputers.csv

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.