Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-Hostname { # PTR lookup with timeout (in whole seconds, unfortunately)
- param( [IPAddress]$IPv4, [Int]$Timeout )
- # Resolve address within requested timeout period
- if ($Timeout) {
- $hostname = (Start-Job { [System.Net.Dns]::GetHostByAddress($input).HostName } -InputObject $IPv4 | Wait-Job -Timeout $Timeout | Receive-Job);
- # Resolve address the normal way that might take a long time to fail
- } else {
- $hostname = [System.Net.Dns]::GetHostByAddress($IPv4).HostName;
- }
- Return $hostname;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement