# 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 pl

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

[Zobacz obrazy (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 *
```

[!\[Tabela PowerShell pokazująca stan zdrowia DFS na sześciu kontrolerach domeny\](/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.

[!\[Szczegółowy wynik Get-WinADDFSHealth dla dwóch kontrolerów domeny\](/wp-content/uploads/2020/02/img_5e4dbd3f8c14a.png)](/wp-content/uploads/2020/02/img_5e4dbd3f8c14a.png)

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

[!\[Widok PowerShell ze szczegółami zdarzenia replikacji DFS dla uszkodzonego kontrolera\](/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.

[!\[Przefiltrowane wyniki kontroli zdrowia DFS dla domeny ad.evotec.xyz\](/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.

[!\[Lista źródeł Invoke-Testimo z wyróżnionym testem DCDFS\](/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
```

[!\[Wynik konsoli Invoke-Testimo dla testu zdrowia DFS DCDFS\](/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.

[!\[Podsumowanie raportu HTML Testimo dla kontroli zdrowia DFS w lesie\](/wp-content/uploads/2020/02/img_5e4ed17f9da22.png)](/wp-content/uploads/2020/02/img_5e4ed17f9da22.png)[!\[Raport HTML Testimo ze szczegółami weryfikacji DFS dla kontrolerów domeny\](/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
```

[!\[Wynik konsoli Invoke-Testimo dla testów DFS, LDAP, insecure bindings i uprawnień GPO\](/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
```

[!\[Raport HTML Testimo łączący kontrole DFS, LDAP, insecure bindings i GPO\](/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**.

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Inspect and convert mixed Office archives with PSWriteOffice](/blog/inspect-and-convert-mixed-office-archives-pswriteoffice/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)

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