Public/Printing/Test-PrinterTraceroute.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Test-PrinterTraceroute { <# .SYNOPSIS Performs a traceroute to a specified IP address. .DESCRIPTION This function performs a traceroute to a specified IP address. It returns the result of the traceroute. If the traceroute succeeds, it displays a success message. If the traceroute fails or an error occurs, it displays an appropriate message. .PARAMETER IPAddress Specifies the IP address to perform the traceroute. .EXAMPLE Test-PrinterTraceroute -IPAddress "192.168.1.100" Performs a traceroute to 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 traceroute succeeds, "Failure" if it fails, and "ERROR" if an error occurs. .NOTES Ensure you have the necessary permissions to perform network tests. #> param ( [string]$IPAddress ) try { $tracerouteResult = Test-NetConnection -ComputerName $IPAddress -TraceRoute if ($tracerouteResult.TraceRoute) { Write-Host "Traceroute to '$IPAddress' succeeded." -ForegroundColor Green RETURN "Success" } else { Write-Host "Traceroute to '$IPAddress' failed." -ForegroundColor Red RETURN "Failure" } } catch { Write-Host "Failed to perform traceroute to '$IPAddress'. Error: $_" -ForegroundColor Red RETURN "ERROR" } } |