Forum Discussion
JimLeary
Jan 14, 2020Copper Contributor
Change The Domain To Search With Powershell
How can I change the domain I query with the Active Directory Module? We have 5 unique root domains. I use Get-ADuser, Get-ADcomputer, Get-ADObject, Get-ADReplicationSubnet, but I can only search wit...
PeterJ_Inobits
Jan 16, 2020Iron Contributor
Hi Jim
I've used this approach in the past assuming that all the domains are in the same forest
Use get-adforest to retrieve list of domains.
For each domain use get-addomain to retrieve list of DC's or the PDCEmulator role holder.
feed that name into the cmdlet using the -server switch..
I've got a working code sample that I can dig out and send to you if you would like