Powershell

From Richard's Wiki
Revision as of 17:19, 6 July 2009 by Rkdrm (Talk | contribs)

Jump to: navigation, search
  • Recursive delete of files:
get-childitem . -include *scc,bin,obj -recurse | foreach ($_) {remove-item -recurse -force $_.fullname}
  • Periodically poll a website and log response times:
$url="http://xml.weather.yahoo.com/forecastrss?p=10036"
$web = new-object system.net.webclient
$datetime = new-object system.datetime
$log = "log.txt"
while (1) {
 $start = [DateTime]::Now
 $zz = $web.DownloadString($url)
 $end = [DateTime]::Now
 $duration = $end - $start
 "" + [DateTime]::Now + ": Duration " + $duration  >> $log
 sleep 60
}