Un esempio C# di come scaricare il sorgente html di una pagina web.
PowerShell: DownloadPage.ps1
$wc = new-object System.Net.WebClient
$wc.Credentials=[System.Net.CredentialCache]::DefaultCredentials
$wc.DownloadString("http://www.sgart.it")
$wc.Dispose()
se vogliamo scrivere il risultato su un file, basta modificare la seconda terza come segue
PowerShell
$wc.DownloadString("http://www.sgart.it") > sgartDownload.txt

Può essere utile per scaricare lo schema di una lista SharePoint 2007 come indicato in questo articolo
PowerShell
$wc = new-object System.Net.WebClient
$wc.Credentials=[System.Net.CredentialCache]::DefaultCredentials
$wc.DownloadString("http://localhost/eventuali_altri_site/_vti_bin/owssvr.dll?Cmd=ExportList&List={guid}")
$wc.Dispose()
ovviamente mettendo il giusto percorso e guid.

Nel caso ci fosse un proxy il codice diventa:
PowerShell
$proxyUrl = "10.0.0.254:8080"
$url = "http://www.sgart.it"

$proxy = new-object System.Net.WebProxy($proxyUrl)
#$cred = get-credential
#$proxy.credentials = $cred.GetNetworkCredential()
#$proxy.Credentials = [System.Net.CredentialCache]::NetworkCredentials
$proxy.UseDefaultCredentials = $true

$wc = new-object System.Net.WebClient
$wc.proxy = $proxy
$wc.DownloadString($url)
$wc.Dispose()
Potrebbe interessarti anche: