How to find the DistinguishedName or OU of a list of devices in CSV / Excel using Powershell / Active Directory?

155 Views Asked by At

I have an Excel / CSV file with a list of computer names, i am trying to find the OU / DistinguishedName that each of these computers belongs to using PowerShell / Active Directory.

I am very new to this and have only gotten to about here:

Get-ADComputer -filter * -searchbase "OU=OUname, DC=DCname"
select DistinguishedName

This just lists all the computers in the OU, but i need to find the OU from the CSV / Excel i have

I have tried using excel / AD export but it doesnt provide desired result and search AD via powershell only finds the whole list of computers

I need to find what OU the devices on my list are in.

Either via importing the CSV or listing each device in the script.

thank you for any help!

0

There are 0 best solutions below