Functions/Networking/Convert-Int64toIP.ps1
function Convert-Int64toIP { Param ( # INT64 number to convert [Parameter(Mandatory=$true,ValueFromPipeline=$true)] [int64] $INT64 ) Process { $IPAddress = (([math]::truncate($INT64/16777216)).tostring()+"."+([math]::truncate(($INT64%16777216)/65536)).tostring()+"."+([math]::truncate(($INT64%65536)/256)).tostring()+"."+([math]::truncate($INT64%256)).tostring() ) $TrueIP = try{[Net.IPAddress]::Parse($IPAddress)}catch{$null} if($TrueIP) {$TrueIP.ipaddresstostring} else {Write-Host "Could not parse IP: $TrueIP" -ForegroundColor Red} } } |