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

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 admin@tenant.onmicrosoft.com -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 admin@tenant.onmicrosoft.com -Site https://tenantname-my.sharepoint.com/personal/firstname_lastname_tenantname_com -IsSiteCollectionAdmin $true
}
  • 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 – Guest Mar 3 '16 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? – grisha Mar 3 '16 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.