Difference between revisions of "Powershell"
From Richard's Wiki
(New page: * Recursive delete of files: get-childitem . -include *scc,bin,obj -recurse | foreach ($_) {remove-item -recurse -force $_.fullname}) |
|||
Line 1: | Line 1: | ||
* Recursive delete of files: | * Recursive delete of files: | ||
get-childitem . -include *scc,bin,obj -recurse | foreach ($_) {remove-item -recurse -force $_.fullname} | get-childitem . -include *scc,bin,obj -recurse | foreach ($_) {remove-item -recurse -force $_.fullname} | ||
+ | |||
+ | * 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 | ||
+ | } |
Revision as of 17:19, 6 July 2009
- Recursive delete of files:
get-childitem . -include *scc,bin,obj -recurse | foreach ($_) {remove-item -recurse -force $_.fullname}
- 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 }