Cyber Security

Test the reachability of all Domain-Controllers: Test-AllDomainController

As the headline says, with this small script you are able to test all your Domain-Controllers with a single command Test-AllDomainController. The simple things are the best, by all means 😉

The Script

Open PowerShell ISE and copy this script in a new project.

function Test-AllDomainController {
$dcs=(Get-ADDomainController -Filter *).Name
foreach ($items in $dcs) {
Test-Connection $items -Count 1}
}

Press the green button to check it.

Unbenannt.PNG

Make it permanent

Create folder in “C:\Program Files\WindowsPowerShell\Modules” and name it PingAllDC. Make sure you save your script there as PingAllDC.psm1. (The folder and the script should have the same name) Close PowerShell and re-open it. The module gets imported automatically and is available for all users.

1.PNG

Get-Module PingAllDC | Format-Table -AutoSize

2.PNG

To view the command’s scriptblock enter

Get-Command Test-AllDomainController | Select-Object -ExpandProperty ScriptBlock

4.PNG

And finally … in Action …

3.PNG

Have fun with Test-AllDomainController.

See also

PowerShell: Notify me when someone is added to the Administrator Group

PowerShell: Alert me, if a Domain-Controller is down

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.