Public/Printing/Test-PrinterDNS.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Test-PrinterDNS { <# .SYNOPSIS Tests DNS resolution for a specified IP address. .DESCRIPTION This function tests the DNS resolution for a specified IP address. It performs a DNS query and returns the result. If the DNS resolution succeeds, it displays a success message. If the DNS resolution fails or an error occurs, it displays an appropriate message. .PARAMETER IPAddress Specifies the IP address to test DNS resolution. .EXAMPLE Test-PrinterDNS -IPAddress "192.168.1.100" Tests DNS resolution for the IP address "192.168.1.100". .INPUTS System.String. The function accepts a string input for the IP address. .OUTPUTS System.String. Returns "Success" if the DNS resolution succeeds, "Failure" if it fails, and "ERROR" if an error occurs. .NOTES Ensure you have the necessary permissions to perform DNS resolution tests. #> param ( [string]$IPAddress ) try { $dnsResult = Resolve-DnsName -Name $IPAddress -ErrorAction SilentlyContinue if ($dnsResult) { Write-Host "DNS resolution for '$IPAddress' succeeded." -ForegroundColor Green RETURN "Success" } else { Write-Host "DNS resolution for '$IPAddress' failed." -ForegroundColor Red RETURN "Failure" } } catch { Write-Host "Failed to resolve DNS for '$IPAddress'. Error: $_" -ForegroundColor Red RETURN "ERROR" } } |