Un esempio
C# di come scaricare il sorgente
html di una pagina web.
$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
$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$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:
$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()