Clear-Host # ============================================================ # DRUCKER / RIP PORT-TEST # ============================================================ $Ergebnisse = @() # ============================================================ # STANDARDPORTS # ============================================================ # TCP Standardports $StandardTCPPorts = @( [PSCustomObject]@{ Port = 9100 Richtung = "PC -> Plotter" Funktion = "RAW Schnittdaten / Hauptport" } [PSCustomObject]@{ Port = 515 Richtung = "PC -> Plotter" Funktion = "LPD/LPR Fallback" } [PSCustomObject]@{ Port = 445 Richtung = "RIP-PC <-> Netz" Funktion = "SMB / Hot Folder / Dateifreigabe" } [PSCustomObject]@{ Port = 139 Richtung = "RIP-PC <-> SCC-PC" Funktion = "NetBIOS Session / SMB Fallback" } [PSCustomObject]@{ Port = 8080 Richtung = "intern" Funktion = "Sync & Deploy" } [PSCustomObject]@{ Port = 8085 Richtung = "intern" Funktion = "HP Drucker-Synchronisation" } [PSCustomObject]@{ Port = 8086 Richtung = "intern" Funktion = "HP Drucker-Synchronisation" } [PSCustomObject]@{ Port = 8090 Richtung = "intern" Funktion = "HP Drucker-Synchronisation" } [PSCustomObject]@{ Port = 80 Richtung = "nach außen" Funktion = "Web-Interface" } [PSCustomObject]@{ Port = 443 Richtung = "nach außen" Funktion = "HTTPS / Web / Cloud / Lizenz" } [PSCustomObject]@{ Port = 30561 Richtung = "intern" Funktion = "EPSON Drucker Synchronisation" } [PSCustomObject]@{ Port = 1947 Richtung = "lokal" Funktion = "Sentinel LDK Lizenzserver" } [PSCustomObject]@{ Port = 51000 Richtung = "intern" Funktion = "Zünd Cut Center Synchronisation" } [PSCustomObject]@{ Port = 5438 Richtung = "lokal" Funktion = "PrintFactory REST API / Web UI" } [PSCustomObject]@{ Port = 5440 Richtung = "lokal" Funktion = "PrintFactory Workflow REST API" } [PSCustomObject]@{ Port = 5536 Richtung = "lokal" Funktion = "PrintFactory Configuration Proxy" } [PSCustomObject]@{ Port = 5470 Richtung = "lokal" Funktion = "PrintFactory Internet Proxy / LicenseServer" } ) # UDP Standardports $StandardUDPPorts = @( [PSCustomObject]@{ Port = 161 Richtung = "PC -> Plotter" Funktion = "SNMP Gerätestatus / Mediengröße" } [PSCustomObject]@{ Port = 162 Richtung = "Plotter -> PC" Funktion = "SNMP Traps / Statusmeldungen" } [PSCustomObject]@{ Port = 137 Richtung = "RIP-PC <-> SCC-PC" Funktion = "NetBIOS Namensauflösung" } [PSCustomObject]@{ Port = 138 Richtung = "RIP-PC <-> SCC-PC" Funktion = "NetBIOS Namensauflösung" } [PSCustomObject]@{ Port = 1947 Richtung = "lokal" Funktion = "Sentinel LDK Lizenzserver" } [PSCustomObject]@{ Port = 5436 Richtung = "lokal" Funktion = "PrintFactory Proxy Discovery" } [PSCustomObject]@{ Port = 5437 Richtung = "lokal" Funktion = "PrintFactory RIP Discovery" } ) # ============================================================ # FUNKTION: TCP TEST # ============================================================ function Test-TCPPort { param ( [string]$IP, [int]$Port ) $TcpClient = New-Object System.Net.Sockets.TcpClient try { $ConnectTask = $TcpClient.ConnectAsync($IP, $Port) if ($ConnectTask.Wait(2000)) { if ($TcpClient.Connected) { return "OFFEN" } else { return "GESCHLOSSEN" } } else { return "TIMEOUT / BLOCKIERT" } } catch { return "GESCHLOSSEN / NICHT ERREICHBAR" } finally { $TcpClient.Close() } } # ============================================================ # FUNKTION: UDP TEST # ============================================================ function Test-UDPPort { param ( [string]$IP, [int]$Port ) $UdpClient = New-Object System.Net.Sockets.UdpClient try { $UdpClient.Connect($IP, $Port) $UdpClient.Client.ReceiveTimeout = 2000 $Byte = [System.Text.Encoding]::ASCII.GetBytes("Ping") [void]$UdpClient.Send( $Byte, $Byte.Length ) $RemoteEndpoint = New-Object System.Net.IPEndPoint( [System.Net.IPAddress]::Any, 0 ) [void]$UdpClient.Receive( [ref]$RemoteEndpoint ) return "ANTWORT ERHALTEN" } catch { if ($_.Exception.InnerException.ErrorCode -eq 10054) { return "GESCHLOSSEN" } else { return "KEINE ANTWORT / BLOCKIERT" } } finally { $UdpClient.Close() } } # ============================================================ # FUNKTION: ERGEBNIS SPEICHERN # ============================================================ function Add-Result { param ( [string]$IP, [int]$Port, [string]$Protokoll, [string]$Richtung, [string]$Funktion, [string]$Ergebnis ) $script:Ergebnisse += [PSCustomObject]@{ IP = $IP Port = $Port Protokoll = $Protokoll Richtung = $Richtung Ergebnis = $Ergebnis Funktion = $Funktion } } # ============================================================ # IP ABFRAGEN # ============================================================ Write-Host "========================================" -ForegroundColor Cyan Write-Host " DRUCKER PORT-TEST" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" do { $IP = Read-Host "IP-Adresse des Druckers / Geräts eingeben" $IPAddress = $null $IPValid = [System.Net.IPAddress]::TryParse( $IP, [ref]$IPAddress ) if (-not $IPValid) { Write-Host "Ungueltige IP-Adresse!" -ForegroundColor Red } } until ($IPValid) # ============================================================ # ICMP / PING # ============================================================ Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " ICMP / PING" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Write-Host "Teste ICMP ..." -NoNewline try { $Ping = Test-Connection -ComputerName $IP -Count 1 -Quiet -ErrorAction Stop if ($Ping) { Write-Host " ERREICHBAR" -ForegroundColor Green Add-Result ` -IP $IP ` -Port 0 ` -Protokoll "ICMP" ` -Richtung "beide" ` -Funktion "Ping / Diagnose" ` -Ergebnis "ERREICHBAR" } } catch { Write-Host " NICHT ERREICHBAR" -ForegroundColor Red Add-Result ` -IP $IP ` -Port 0 ` -Protokoll "ICMP" ` -Richtung "beide" ` -Funktion "Ping / Diagnose" ` -Ergebnis "NICHT ERREICHBAR" } # ============================================================ # TCP STANDARDPORTS # ============================================================ Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " STANDARD TCP PORTS" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" foreach ($Eintrag in $StandardTCPPorts) { $Port = $Eintrag.Port Write-Host ("Teste TCP {0} ... " -f $Port) -NoNewline $Status = Test-TCPPort ` -IP $IP ` -Port $Port if ($Status -eq "OFFEN") { Write-Host "OFFEN" -ForegroundColor Green } elseif ($Status -like "GESCHLOSSEN*") { Write-Host "GESCHLOSSEN" -ForegroundColor Red } else { Write-Host $Status -ForegroundColor Yellow } Add-Result ` -IP $IP ` -Port $Port ` -Protokoll "TCP" ` -Richtung $Eintrag.Richtung ` -Funktion $Eintrag.Funktion ` -Ergebnis $Status } # ============================================================ # UDP STANDARDPORTS # ============================================================ Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " STANDARD UDP PORTS" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" foreach ($Eintrag in $StandardUDPPorts) { $Port = $Eintrag.Port Write-Host ("Teste UDP {0} ... " -f $Port) -NoNewline $Status = Test-UDPPort ` -IP $IP ` -Port $Port if ($Status -eq "ANTWORT ERHALTEN") { Write-Host "ANTWORT ERHALTEN" -ForegroundColor Green } elseif ($Status -eq "GESCHLOSSEN") { Write-Host "GESCHLOSSEN" -ForegroundColor Red } else { Write-Host $Status -ForegroundColor Yellow } Add-Result ` -IP $IP ` -Port $Port ` -Protokoll "UDP" ` -Richtung $Eintrag.Richtung ` -Funktion $Eintrag.Funktion ` -Ergebnis $Status } # ============================================================ # HINWEIS DYNAMISCHE PORTS # ============================================================ Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " DYNAMISCHE TCP PORTS" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Write-Host "Caldera verwendet für RPC dynamische TCP-Ports" -ForegroundColor Yellow Write-Host "im Bereich 1024-65535." -ForegroundColor Yellow Write-Host "" Write-Host "Dieser Bereich wird NICHT automatisch komplett gescannt." -ForegroundColor Yellow Write-Host "Einzelne Ports können anschließend als eigene Ports getestet werden." -ForegroundColor Yellow # ============================================================ # EIGENE TCP PORTS # ============================================================ Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " EIGENE TCP PORTS" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Write-Host "Mehrere Ports mit Komma trennen." -ForegroundColor Gray Write-Host "Beispiel: 10000,12000,50000" -ForegroundColor Gray Write-Host "Leer lassen = keine eigenen TCP-Ports" -ForegroundColor Gray Write-Host "" $CustomTCPInput = Read-Host "Eigene TCP-Ports" if (-not [string]::IsNullOrWhiteSpace($CustomTCPInput)) { $CustomTCPPorts = $CustomTCPInput -split "," | ForEach-Object { $_.Trim() } | Where-Object { $_ -match '^\d+$' -and [int]$_ -ge 1 -and [int]$_ -le 65535 } | ForEach-Object { [int]$_ } | Select-Object -Unique foreach ($Port in $CustomTCPPorts) { Write-Host ("Teste TCP {0} ... " -f $Port) -NoNewline $Status = Test-TCPPort ` -IP $IP ` -Port $Port if ($Status -eq "OFFEN") { Write-Host "OFFEN" -ForegroundColor Green } elseif ($Status -like "GESCHLOSSEN*") { Write-Host "GESCHLOSSEN" -ForegroundColor Red } else { Write-Host $Status -ForegroundColor Yellow } Add-Result ` -IP $IP ` -Port $Port ` -Protokoll "TCP" ` -Richtung "Benutzerdefiniert" ` -Funktion "Eigener Port" ` -Ergebnis $Status } } # ============================================================ # EIGENE UDP PORTS # ============================================================ Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " EIGENE UDP PORTS" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Write-Host "Mehrere Ports mit Komma trennen." -ForegroundColor Gray Write-Host "Beispiel: 5000,5436,5437" -ForegroundColor Gray Write-Host "Leer lassen = keine eigenen UDP-Ports" -ForegroundColor Gray Write-Host "" $CustomUDPInput = Read-Host "Eigene UDP-Ports" if (-not [string]::IsNullOrWhiteSpace($CustomUDPInput)) { $CustomUDPPorts = $CustomUDPInput -split "," | ForEach-Object { $_.Trim() } | Where-Object { $_ -match '^\d+$' -and [int]$_ -ge 1 -and [int]$_ -le 65535 } | ForEach-Object { [int]$_ } | Select-Object -Unique foreach ($Port in $CustomUDPPorts) { Write-Host ("Teste UDP {0} ... " -f $Port) -NoNewline $Status = Test-UDPPort ` -IP $IP ` -Port $Port if ($Status -eq "ANTWORT ERHALTEN") { Write-Host "ANTWORT ERHALTEN" -ForegroundColor Green } elseif ($Status -eq "GESCHLOSSEN") { Write-Host "GESCHLOSSEN" -ForegroundColor Red } else { Write-Host $Status -ForegroundColor Yellow } Add-Result ` -IP $IP ` -Port $Port ` -Protokoll "UDP" ` -Richtung "Benutzerdefiniert" ` -Funktion "Eigener Port" ` -Ergebnis $Status } } # ============================================================ # GESAMTERGEBNIS # ============================================================ Write-Host "" Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " GESAMTERGEBNIS" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" $Ergebnisse | Format-Table ` IP, Port, Protokoll, Ergebnis, Richtung, Funktion ` -AutoSize Write-Host "" Write-Host "Test für $IP abgeschlossen." -ForegroundColor Green Write-Host "" Read-Host "Enter drücken zum Beenden"