Parity123
asked on
Powershell: Search computers in AD
Hello Experts,
I need assistance with a query that would search the computer object in the forest, and return the dnshostname of the computer object. I have a file with 100+ computer names. There are about 10 domains in the forest, and the computer object could be in any of the domains. The following line only looks at the domain I am logged in.
Get-ADComputer <computer name> | select dnshostname
Thanks much for your help.
I need assistance with a query that would search the computer object in the forest, and return the dnshostname of the computer object. I have a file with 100+ computer names. There are about 10 domains in the forest, and the computer object could be in any of the domains. The following line only looks at the domain I am logged in.
Get-ADComputer <computer name> | select dnshostname
Thanks much for your help.
ASKER
I don't know which domain the computer belongs to. I want to query AD for the computers and return the dnshostname. There are a few hundred thousand computer objects, putting them in an array will not work, and is very tedious.
That's not correct- if you are going to be looking for an object(s) across multiple domains you need to put the info into array or data table, otherwise looking for 100 computers will take an hour instead of 30 seconds because you requery each domain each time (SLOW!). You want to collect the information ONCE and then look through it in memory.
If you want a more specific answer you need to provide more specific information about your environment domain/forest setup.
If you want a more specific answer you need to provide more specific information about your environment domain/forest setup.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much
The asker seemed to have gotten an acceptable answer from oBdA.
Open in new window
Then just drop the computers into an array or datatable for each domain and you're all set.