Created
May 29, 2025 17:26
-
-
Save smitmartijn/944fc2e2a41af5dd7aef6b50afb7b91e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nuclear restart of SSHD and all connections | |
$sshConnections = Get-NetTCPConnection -LocalPort 22 -State Established -ErrorAction SilentlyContinue | |
Stop-Service sshd | |
foreach ($conn in $sshConnections) { | |
$process = Get-Process -Id $conn.OwningProcess -ErrorAction SilentlyContinue | |
if ($process) { | |
Stop-Process -Id $process.Id -Force | |
} | |
} | |
Start-Service sshd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment