Posts
49
Comments
83
Trackbacks
0
MSH Script: Get-URI

This was one of the first scripts I wrote in MSH (see Monad). Lee and Adam actually work on Monad so they take time to explain things, I'm just going to paste it with a brief summary since its not doing anything fancy. Update: Lee improved the script to use new features available in latest builds. Be sure to check it out!

##
## Vivek Sharma (viveksharma.com) - 1/4/05
## Simple script to get a web page… Can’t really handle https
## or complex cookies.
##
if ($args.Length -eq 0)
{
 write-object “`nYou did not pass in a URI`n”; return }
 $webclient = [activator]::createinstance([System.Net.WebClient])
 $webclient.Headers.Add(”user-agent”, “Mozilla/4.0 (compatible; MSIE      6.0; Windows NT 5.2; .NET CLR 1.0.3705;)”)
 $stream = $webclient.OpenRead($args[0])
 $streamreader = [activator]::createinstance([System.IO.StreamReader],     $stream)
 if (!$streamreader)
 { return }
 [String[]]$sarray = @()
 while(! $streamreader.EndOfStream )
 {      $sarray += $streamreader.ReadLine()
}
$sarray
posted on Saturday, August 06, 2005 11:08 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 3 and 7 and type the answer here:
News
A little slow these days as I'm busy working on exchangelabs.com. I will try and post tidbits when I get some time. Enjoy the older posts till then!