# Beschreibung: - # Autor: Patrick Asmus # Web: https://www.techniverse.net # Version: 1.0 # Datum: 18.03.2025 # Modifikation: Initial ##################################################### param ( [string]$Domain, [string]$RecordType, [string]$DNSServer ) # Sicherstellen, dass alle Parameter gesetzt sind if (-not $Domain -or -not $RecordType -or -not $DNSServer) { Write-Output "1Fehlende Parameter! Nutzung: -Domain example.com -RecordType A -DNSServer ns1.example.com" exit 1 } # Timeout-Handling: Prüfe, ob der DNS-Server erreichbar ist $PingResult = Test-NetConnection -ComputerName $DNSServer -Port 53 -WarningAction SilentlyContinue -InformationLevel Quiet if (-not $PingResult) { Write-Output "1DNS-Server $DNSServer nicht erreichbar!" exit 1 } # DNS-Abfrage ausführen try { $Result = Resolve-DnsName -Name $Domain -Type $RecordType -Server $DNSServer -ErrorAction Stop # Je nach Record-Typ unterschiedliche Rückgabe-Informationen extrahieren switch ($RecordType.ToUpper()) { "A" { $RecordData = $Result.IPAddress } "AAAA" { $RecordData = $Result.IPAddress } "MX" { $RecordData = $Result.NameExchange } "TXT" { $RecordData = ($Result.Strings -join ", ") } "CNAME" { $RecordData = $Result.NameHost } "NS" { $RecordData = $Result.NameHost } default { $RecordData = "Unbekannter Record-Typ: $RecordType" } } $Status = 1 # Erfolgreich } catch { $RecordData = "Fehler: Keine Antwort von $DNSServer für $RecordType" $Status = 0 # Fehler } # XML-Ausgabe für PRTG $xml = @" $RecordType Record $Status prtg.standardlookups.yesno.stateyesok $RecordType for ${Domain}: ${RecordData} "@ Write-Output $xml