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