Forum Discussion
Rob M
Nov 22, 2021Copper Contributor
Get all AD computers excluding servers
Hi! I am trying to create a script that will retrieve all computers but exclude any servers found. I also discovered that using the most basic command will return about two dozen servers and then cr...
J Mymryk
Nov 22, 2021Copper Contributor
Hi, my best guess is that it is finding an object in AD that is corrupted and therfore throws an exception. you may want to try the older method of adsisearcher as per:
https://social.technet.microsoft.com/Forums/en-US/ec2732b9-d2dd-4592-82bc-71fae700a81b/powershell-list-all-servers-in-the-domain-and-the-ou?forum=ITCG
Have you done AD health checks to make sure you don't have orphan or corrupt objects?
https://social.technet.microsoft.com/Forums/en-US/ec2732b9-d2dd-4592-82bc-71fae700a81b/powershell-list-all-servers-in-the-domain-and-the-ou?forum=ITCG
Have you done AD health checks to make sure you don't have orphan or corrupt objects?
Rob M
Nov 23, 2021Copper Contributor
I looked into this further by testing against all domains. Get-ADComputer works on all domains except for one. How do I determine the root cause so I can escalate this issue to another team?
You are definitely on the right track. 🙂
You are definitely on the right track. 🙂
- Rob MNov 23, 2021Copper ContributorWell, this apparently known in my organization. The workaround is to include specific properties in the line of script.
So in our environment, one of our domains will fail when you use -Properties *
If I use, -Properties CN,OperatingSystem, then the script no longer crashes on the domain causing issues.