2009/11/21

PowerShell examples

ping an ip address range and report which hosts are down:
PS H:\> for ( $i=200; $i -lt 255; $i++ ) { ping -n 1 -a -w 1000 192.168.0.$i > $null; if (!$?) { echo "192.168.0.$i is
down" }; }

Send an email with attachments (like logs), quick and dirty:
send-mailmessage -to me@foo.com -Subject "see attachment" -from myhost@foo.com -attachments "C:\bar.log" -smtpserver mail.foo.com

No comments: