How can I download the contents of a page on my SharePoint Online (Office 365) environment using PowerShell? This is an
.aspx page - I am looking for the rendered/html version, same as if I went there on my browser, not looking for the source code.
I would prefer a simple
WebRequest call, but haven't been able to get the credentialing to work. I have tried many variations of the following, all of which return a 403:
$webclient = new-object System.Net.WebClient $webclient.Credentials = new-object System.Net.NetworkCredential($username, $password) $webclient.AuthenticationMode = "FormsAuthentication" $webclient.FormsAuthenticationLoginInfo = New-Object Microsoft.SharePoint.Client.FormsAuthenticationLoginInfo($username, $password)
I have also tried the SharePoint Online client libraries. I can successfully connect to my environment using the code below, but don't know how to request a particular page from there:
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)