Invoke-WebRequest Authentication with SharePoint Online

Copper Contributor

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 "" -Credential (Get-Credential) -ErrorAction Stop
    # This will only execute if the Invoke-WebRequest is successful.
    $StatusCode = $Response.StatusCode
    $StatusCode = $_.Exception.Response.StatusCode.value__



1 Reply
Hi, did you manage to find a solution? I am experiencing the same issue.