PowerShell - Check All DC's for ping and defined TCP port success
- Jon Boyette
- Jan 10, 2022
- 1 min read
Save as a PortChecker.ps1, runs and gets DC's with defined port entered after launching, then outgrids to screen the DC's and results
$a = Read-Host "Enter the Port For OutGrid View Across Domain"
# Get your ad domain
$DomainName = (Get-ADDomain).DNSRoot
# Get all DC's
$AllDCs = Get-ADDomainController -Filter * -Server $DomainName
# Using one-liner - Get all DC's and test connection on port entered
(Get-ADDomainController -Filter * -Server $((Get-ADDomain).DNSRoot)).Hostname |
Foreach{Test-NetConnection -ComputerName $_ -Port $a -InformationLevel Detailed} |
Out-GridView -Title "Results"
Comments