### Test-NetConnection function
```powershell
Test-NetConnection -Port 445 <IP>
Test-NetConnection -Port 25 <IP>
```
### Scan the first 1024 ports on the DC with Powershell one-liner
엄청 느림
```powershell
1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("<IP>", $_)) "TCP port $_ is open"} 2>$null
```
### 빠른 버전
```powershell
1..1024 | % {
$port = $_
$client = New-Object System.Net.Sockets.TcpClient
$connectTask = $client.ConnectAsync("<IP>", $port)
if ($connectTask.Wait(200)) { # 200ms timeout
Write-Output "TCP port $port is open"
$client.Close()
}
}
```