How do you authenticate with SharePoint Online with Invoke-WebRequest? I have tried following which returns status 200, OK but it doesn't mean login was successful. I would like to list all URLs from a site. the $response.Links doesn't return anything.
$response = Invoke-WebRequest -Uri "https://xxx365.sharepoint.com" -Credential (Get-Credential) -ErrorAction Stop
# This will only execute if the Invoke-WebRequest is successful.
$StatusCode = $Response.StatusCode
$StatusCode = $_.Exception.Response.StatusCode.value__