# Active Directory DFS Health Check with PowerShell

One of the critical parts of Active Directory is DFS. It allows you to share same NETLOGON/SYSVOL folders across all Domain Controllers in your Forest. Its health is vital to the functionality of your Active Directory. If it’s broken, a lot of things may not work, and it’s not that easy to tell the status of it. At first sight, everything may seem to work correctly, but if you take a closer look – not so much. It’s great if you find it out by yourself, but not fun if suddenly GPO’s don’t apply to some users, computers, and you find out a year later.

blog

20 Feb 2020 en

![Active Directory DFS Health Check with PowerShell](/wp-content/uploads/2020/02/img_5e4dbd3f8c14a.png)

[View images (10)](#pf-content-image-1-0)

One of the critical parts of **Active Directory** is **DFS**. It allows you to share same **NETLOGON/SYSVOL** folders across all **Domain Controllers** in your Forest. Its health is vital to the functionality of your **Active Directory**. If it's broken, a lot of things may not work, and it's not that easy to tell the status of it. At first sight, everything may seem to work correctly, but if you take a closer look – not so much. It's great if you find it out by yourself, but not fun if suddenly **GPO's **don't apply to some users, computers, and you find out a year later.

### 💡 Get-WinADDFSHealth for DFS Health Check needs

So what to do? Verify that your DFS is healthy on all your DC's, and do it frequently enough. For this purpose I've automated this process and created a single function Get-WinADDFSHealth.

```powershell
Get-WinADDFSHealth | Format-Table -AutoSize *
```

[!\[PowerShell table showing DFS health status for six domain controllers\](/wp-content/uploads/2020/02/img_5e4c59c2b1809.png)](/wp-content/uploads/2020/02/img_5e4c59c2b1809.png)

As you can see above, the **Get-WinADDFSHealth** function does a lot of verifications on each **DC**. It verifies replication is healthy, **GPO **count matching **SYSVOL** count, and multiple other settings. In case something is wrong, one can asses this quickly by checking the **Status **command. Of course, not everything fits into the screen. If we check details for each **DC**, we can get more information.

[!\[Detailed Get-WinADDFSHealth output for two domain controllers\](/wp-content/uploads/2020/02/img_5e4dbd3f8c14a.png)](/wp-content/uploads/2020/02/img_5e4dbd3f8c14a.png)

Additionally **DFSEvents** are provided for quick assesment.

[!\[PowerShell view of DFS replication event details for a failed controller\](/wp-content/uploads/2020/02/img_5e4dbdc2b70ad.png)](/wp-content/uploads/2020/02/img_5e4dbdc2b70ad.png)

You can also limit the amount of **DCs **for testing. You can use **SkipRODC**, **IncludeDomains**, **ExcludeDomains**, **IncludeDomainControllers** and **ExcludeDomainControllers**. This allows you to be flexible with what you want to test at any given moment.

[!\[Filtered DFS health check results for the ad.evotec.xyz domain\](/wp-content/uploads/2020/02/img_5e4dbeb04f389.png)](/wp-content/uploads/2020/02/img_5e4dbeb04f389.png)

### 💡 You have convinced me! How do I proceed?

This function is available as part of the **[ADEssentials](https://github.com/EvotecIT/ADEssentials)** module. It also requires Administrative privileges (**Domain Admin** or similar) You also need to have **ActiveDirectory** and **GPO** module installed from **RSAT**. That's a standard for Domain Admins.

```powershell
Install-Module ADEssentials -Force
```

After installing or updating that module, you're good to go, and the above commands should be available. As always, **before running anything on production, make sure to test in the test environment** and** review source codes** that I provide on **GitHub**.

### 💡 Automating DFS Replication Health Check

Now that you know the **Get-WinADDFSHealth** command, I wanted to remind you that this command is used as part of Testimo. If you never heard of Testimo, it's worth to read “**[What do we say to health checking Active Directory?](https://evotec.xyz/what-do-we-say-to-health-checking-active-directory/)” **blog post. It's not up to date with all the features it currently has, but it should give you an idea of what it is about. In short, with just a single command, it's able to provide a health check of your entire **Active Directory**. It works on defaults that I've defined, but everyone can modify settings in configuration files to match their environment needs. **Testimo **is heavy work in progress, and I keep on adding more tests and enhancements.

Why mentioning it now? When you install **Testimo**, you get a single command called **Invoke-Testimo**. You can run it without any parameters, which will trigger a full scan and provide you a “quick” overview of potential problems. The word quick is not a good description because if your Forest\Domain has multiple DCs, this is going to take a while. However, Testimo also provides an easy way to pick the tests you want.

[!\[Invoke-Testimo source list highlighting the DCDFS test\](/wp-content/uploads/2020/02/img_5e4ed01ea8489.png)](/wp-content/uploads/2020/02/img_5e4ed01ea8489.png)

As you can see above, there are a lot of defined tests you can use. To execute **Get-WinADDFSHealth**, but through **Invoke-Testimo**, you can use the following command:

```powershell
Invoke-Testimo -Sources DCDFS
```

[!\[Invoke-Testimo console output for the DCDFS DFS health test\](/wp-content/uploads/2020/02/img_5e4ed1088433e.png)](/wp-content/uploads/2020/02/img_5e4ed1088433e.png)

As you can see, **[Testimo](https://github.com/EvotecIT/Testimo) **did a health assessment of your **DFS **using internally **Get-WinADDFSHealth** command. You can also use the same command with **ShowReport** switch, which triggers an **HTML **summary for **DCFS**, but also providing details that you can verify.

```powershell
Invoke-Testimo -Sources DCDFS -ShowReport
```

As you can see, **[Testimo](https://github.com/EvotecIT/Testimo) **did a health assessment of your **DFS **using internally **Get-WinADDFSHealth** command. You can also use the same command with **ShowReport** switch, which triggers an **HTML **summary for **DCFS**, but also providing details that you can verify. Each report has a diagram, exact code that was used to generate it the results which you can use separately, output table with details from that command and finally results of assessment.

[!\[Testimo HTML report summary for DFS health checks across the forest\](/wp-content/uploads/2020/02/img_5e4ed17f9da22.png)](/wp-content/uploads/2020/02/img_5e4ed17f9da22.png)[!\[Testimo HTML report with per-domain-controller DFS verification details\](/wp-content/uploads/2020/02/img_5e4ed19cd083c.png)](/wp-content/uploads/2020/02/img_5e4ed19cd083c.png)

Of course, that's just one test executed on six **Domain Controllers**. **Testimo** can be performed without parameters doing **30+ tests** in one go, or you can handpick multiple ones that are of interest to you. Do you remember the last articles?

- 📝 [Finding GPOs missing permissions that may prevent GPOs from working correctly](https://evotec.xyz/finding-gpos-missing-permissions-that-may-prevent-gpos-from-working-correctly/)
- 📝 [Four commands to help you track down insecure LDAP Bindings before March 2020](https://evotec.xyz/four-commands-to-help-you-track-down-insecure-ldap-bindings-before-march-2020/)

Both of those blog posts covered commands from ADEssentials and [Testimo](https://github.com/EvotecIT/Testimo) uses them internally to make sure AD is healthy without much effort on the operations. You can schedule it or do adhoc tests. Up to you.

```powershell
Invoke-Testimo -Sources DCDFS,DCLDAP,DCLDAPInsecureBindings,DomainGroupPolicyMissingPermissions
```

[!\[Invoke-Testimo console output for DFS, LDAP, insecure binding, and GPO permission checks\](/wp-content/uploads/2020/02/img_5e4ed3b3883c0.png)](/wp-content/uploads/2020/02/img_5e4ed3b3883c0.png)

Whether it's just one source or multiple sources **ShowReport** switch can be used as well

```powershell
 Invoke-Testimo -Sources DCDFS,DCLDAP,DCLDAPInsecureBindings,DomainGroupPolicyMissingPermissions -ShowReport
```

[!\[Testimo HTML report combining DFS, LDAP, insecure binding, and GPO checks\](/wp-content/uploads/2020/02/img_5e4ed447219e4.png)](/wp-content/uploads/2020/02/img_5e4ed447219e4.png)

[Testimo](https://github.com/EvotecIT/Testimo) is one of my favorite **PowerShell **modules that I frequently use for quick or not so quick assessment of **Active Directory**. I don't have to remember all the commands for testing **LDAP**, finding whether **DFS **is functioning correctly or checking if **Active Directory** replication is working as expected.

### 💡 You have convinced me! How do I proceed?

Installing [Testimo](https://github.com/EvotecIT/Testimo) is as easy as using [ADEssentials](https://github.com/EvotecIT/ADEssentials).

```powershell
Install-Module Testimo -Force
```

After installing or updating that module, you're good to go, and the above commands should be available. As always, **before running anything on production, make sure to test in the test environment** and** review source codes** that I provide on **GitHub**.

## Related Projects

Projects that align with this post's tags, categories, and content.

[All projects](/projects/)

Matching projects...

[Back to Blog](/blog)

## Related posts

- [Finding duplicate SPN with PowerShell](/blog/finding-duplicate-spn-with-powershell/)
- [Active Directory Domain Services could not replicate the directory partition – The replication operation encountered a database error](/blog/active-directory-domain-services-could-not-replicate-the-directory-partition-the-replication-operation-encountered-a-database-error/)
- [Finding GPOs missing permissions that may prevent GPOs from working correctly](/blog/finding-gpos-missing-permissions-that-may-prevent-gpos-from-working-correctly/)

<!-- PowerForge markdown artifact sha256:6FFC6ED0C583FF771F2A948B5DEBED4E93A1BDD0356CC1BA6B3F68F0D0CAE388 -->
