Getting the raw html of a website can be helpful when you want to search for specific text or are building a web scraping application. It can also be handy if you need to set up some kind of automation that interacts with a web site such as downloading a file. The .NET Framework's WebClient class includes some methods for getting the source of a web page.
The code below defines a url variable and then grabs the HTML into another variable:
# Create a WebClient object
$webClient = New-Object System.Net.Webclient
# The URL we want to get the HTML for
$url = "http://www.blogs.rememberwhens.com"
# Download the raw HTML
$rawHTML = $webClient.DownloadString($url)
# Define regular expression pattern
$reg = "<(?i:Title)>(?(\D*?))(?i:Title)>"
#
# Match content within the tags
#
$groups = [System.Text.RegularExpressions.RegEx]::Match($rawHtml,$reg).Groups
# Get the match in the TitleContent group which will be the title
$title = $groups["titleContent"].value
$webClient.DownloadString($url) | Out-File -FilePath C:\WebBackup\SiteHTML.txt