Skip to content

Commit

Permalink
Update ./scripts/Checks/is RDP port ok.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
P6g9YHK6 committed Dec 20, 2024
1 parent 5df7518 commit 70673dc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts_staging/Checks/is RDP port ok.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
.CHANGELOG
12.12.24 SAN Changed outputs
20.12.24 SAN Changed outputs
#>

$port = 3389
Expand All @@ -24,20 +24,20 @@ $address = "localhost"
if (Get-Command Test-NetConnection -ErrorAction SilentlyContinue) {
$tcpConnection = Test-NetConnection -ComputerName $address -Port $port
if ($tcpConnection.TcpTestSucceeded) {
Write-Output "RDP is open."
Write-Output "OK: RDP is open."
} else {
Write-Output "Port $port is not open RDP will not work."
Write-Output "KO: Port $port is not open RDP will not work."
exit 1
}
} else {
# Fallback using TcpClient
try {
$tcpClient = New-Object System.Net.Sockets.TcpClient
$tcpClient.Connect($address, $port)
Write-Output "RDP is open but TNC does not work."
Write-Output "OK: RDP is open but TNC does not work."
$tcpClient.Close()
} catch {
Write-Output "Port $port is not open and TNC does not work."
Write-Output "KO: Port $port is not open and TNC does not work."
exit 1
}
}

0 comments on commit 70673dc

Please sign in to comment.