Connecting to OneDrive using the Teanant admin credentials getting 403

Copper Contributor

 

I have strange behaviour. We have around 250 OneDrives in my tenanat and i want to get the list and creation date using the SPO and PNP powershell.

I get the most of the One drives data but for about 50 OneDrives i am getting the 403 forbidden error.

same policy is used for all onedrives, nothing special. i can get the details from get-sposite but connect-pnponline throwing this error.

Any idea? thank you

Connect-PnPOnline -Url $s.Url -UseWebLogin
Connect-PnPOnline : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ Connect-PnPOnline -Url $s.Url -UseWebLogin
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], WebException
+ FullyQualifiedErrorId : System.Net.WebException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline

2 Replies

@Waqas sarwar 

 

If you still have this problem, you can try without -UseWebLogin

 

Connect-PnPOnline -Url $s.Url -Credentials (Get-Credential)

 

@Kevin Morgan  No luck, as i mentioned it is random. I looped all one driver and some throws the error.