2

Just using your script to grab the OD4B usage details, when running the script I'm receiving below error each time it queries someone's URL. Any ideas? I'm running the script as an O365 Global Admin.

an access denied and 401 unauthorized message

This is what it looks like for each OD4B site the script queries:

Storage: Percentage used: Storage free: 1099511627776 Processing https://tenantname-my.sharepoint.com/personal/firstname_lastname_tenantname_com Exception calling "ExecuteQuery" with "0" argument(s): "Access denied. You do not have permission to perform this acti At C:\Users\Matt\Downloads\UsageReportWithCSOM.ps1:56 char:3 + $ctx.ExecuteQuery() + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ServerUnauthorizedAccessException

Percentage used: Storage free: 1099511627776 Processing https://tenantname-my.sharepoint.com/personal/firstname_lastname_tenantname_com Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (401) Unauthorized." At C:\Users\Matt\Downloads\UsageReportWithCSOM.ps1:52 char:3 + $ctx.ExecuteQuery() + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : WebException

1 Answer 1

1

I see you are accessing personal sites of your users. Do you have access to them, e.g. when you paste in the browser https://tenantname-my.sharepoint.com/personal/firstname_lastname_tenantname_com?

If not, you can temporarily assign yourself as the site admin for the users, using

Set-SPOUser [email protected] -Site https://tenantname-my.sharepoint.com/personal/firstname_lastname_tenantname_com -IsSiteCollectionAdmin $true

For example:

$users=(Get-SPOUser -Site https://TENANT-my.sharepoint.com).LoginName
foreach($user in $users)
{

Set-SPOUser [email protected] -Site https://tenantname-my.sharepoint.com/personal/firstname_lastname_tenantname_com -IsSiteCollectionAdmin $true
}
2
  • I can access the personal sites of your users. When paste in the browser tenantname-my.sharepoint.com/personal/…? and enter my credentials I can open their one drive files Commented Mar 3, 2016 at 12:33
  • What happens if you run Set-SPOUser for one of the affected sites and then try to pull the usage report for that site? Does it work? Does the error change? Commented Mar 3, 2016 at 12:49

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.