View tping.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$ip = "8.8.8.8" | |
) | |
do { | |
$ping = Test-Connection $ip -Count 1 -ErrorAction SilentlyContinue | |
if ($ping -eq $null) { | |
$host.UI.RawUI.WindowTitle = "Ping: timeout" | |
write-host "Ping $ip : timeout" | |
} else { |
View gist:bfa6df9e6d69c5e5c7a5c63591ad2fcf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logicalpath($path) { | |
// same as realpath() except keeps logical paths | |
if (!file_exists($path)) { | |
return False; | |
} | |
$filename = ''; | |
if (is_file($path)) { | |
$filename = (basename($path)); | |
$length = strlen($filename); | |
$path = substr($path, 0, -$length); |