# Which domain controllers are all computers authenticating to?

**URL:** <https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153>\
**Category:** PowerShell Help\
**Created:** [August 8, 2017, 8:14am UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153 "2017-08-08T08:14:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanoinglewood](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@kanoinglewood](https://forums.powershell.org/u/kanoinglewood)\
**Post date:** [August 8, 2017, 8:14am UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153/1 "2017-08-08T08:14:02Z")

</div>

I was tasked with writing a script (see below) to determine which domain controllers all computers are using for authentication.

Get-ADComputer -filter \* -Searchbase “OU=ourcomputerOU,DC=domain,DC=AD” | %{Get-WmiObject -Class win32\_ntdomain -Filter “DomainName = ‘ourdomain’” -ComputerName $\_.Name} | Export-csv c:\temp\logon.csv

After I ran the script and based on how large our organization is and the number of computers that are deployed, I thought I would have seen more computers listed in my output file logon.csv. The following errors below repeat multiple times as the script is running. I ran the script during different hours of the day with the same results. What stands out is “The RPC server is unavailable.” Any comments or suggestion will be appreciated.

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)  
At line:1 char:79

- … ,DC=AD" | %{Get-WmiObject -Class win32\_ntdomain -Filter "DomainName = …
- 

```
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidOperation: (🙂 [Get-WmiObject], COMException
  - FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Thanks,  
Kano

---

<div class="post-metadata">

**Author:** ![sanchez](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@sanchez](https://forums.powershell.org/u/sanchez)\
**Post date:** [August 8, 2017, 8:29am UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153/2 "2017-08-08T08:29:57Z")

</div>

Did you try any of the stuff in the other thread you started about this?

[https://powershell.org/forums/topic/what-domain-controllers-are-computers-authenticating-to/#post-76339](https://powershell.org/forums/topic/what-domain-controllers-are-computers-authenticating-to/#post-76339)

---

<div class="post-metadata">

**Author:** ![simbrook](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@simbrook](https://forums.powershell.org/u/simbrook)\
**Post date:** [August 8, 2017, 8:35am UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153/3 "2017-08-08T08:35:24Z")

</div>

It could be firewall rules on some of your machines

> **[Troubleshooting 'RPC server unavailable' 0x800706BA - \[SOLVED\] enterprise IT](https://enterpriseit.co/windows-server/rpc-server-unavailable-0x800706ba/)**
>
> Issue: You are getting the error: “The RPC Server is unavailable. (Exception from HRESULT: 0x800706BA)” Cause: This error is likely caused by the RPC ports being blocked between the servers involved in the communication or server process...

Have you thought of adding the query to a logon script and have this write to a central file or database ?  
i.e. in dos write the result of  
echo %logonserver%

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [August 8, 2017, 9:45am UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153/4 "2017-08-08T09:45:01Z")

</div>

RPC server unavailable means that you can’t make a connection to WMI on the remote machine. The commonest cause for this is a firewall is blocking DCOM.

---

<div class="post-metadata">

**Author:** ![dsf3g](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dsf3g](https://forums.powershell.org/u/dsf3g)\
**Post date:** [August 9, 2017, 6:14am UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153/5 "2017-08-09T06:14:51Z")

</div>

A few things other than firewalls to keep in mind:

1. You may have a significant number of stale computer objects in your environment. Query all computer objects for password last set and create an input file based only on machine that have changed their passwords in the last 60 days

2. Take that first list and run a test-connection against the machines. The machines that respond are live in your environment. If you can query them then do so and make note of machines that were down. Remember, unlike servers, workstations are frequently powered down by their owners. Run subsequent queries only against that smaller list from time to time and generate narrower lists as you go.

---

<div class="post-metadata">

**Author:** ![simbrook](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@simbrook](https://forums.powershell.org/u/simbrook)\
**Post date:** [August 9, 2017, 6:18am UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153/6 "2017-08-09T06:18:25Z")

</div>

you could do this from a logon script

echo %logonserver% \>\> path to txt file

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:37pm UTC](https://forums.powershell.org/t/which-domain-controllers-are-all-computers-authenticating-to/9153/7 "2024-05-16T20:37:44Z")

</div>


