RDP-Testing

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
$VMs = @(
"server1.domain.ch"
)
 
$Port = 3389
$Logfile = "C:\Temp\RDPTrace.txt"
$enddate = (Get-Date).AddDays(1)
 
while ((get-date) -le $enddate){
 
    foreach ($VM in $VMs){
    $Output = Test-NetConnection -ComputerName $VM -Port $port -WarningAction SilentlyContinue
 
    if (!$Output.TcpTestSucceeded -eq $true){
       $timestamp = get-date
       $logtext = "$timestamp : Test auf $VM mit Port TCP $port not Successful"
       Add-Content -Path $Logfile -Value $logtext
    }
      Start-Sleep -Seconds 1
    }
}