I am using an account that is a global admin of our 365 tennant.
I am using the code from Office to get a list of OneDrives: https://support.office.com/en-us/article/How-to-display-a-list-of-OneDrive-for-Business-site-collections-8e200cb2-c768-49cb-88ec-53493e8ad80a
I am getting an exception, Unable to process, unauthorized…
Exception calling "GetUserProfileByName" with "1" argument(s): "Server was unable to process request. ---> Attempted to perform an unauthorized operation." At line:1 char:1 + $ UserProfileService.GetUserProfileByName("will gazall") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapException
The line its failing at is:
$ UserProfileResult = $ UserProfileService.GetUserProfileByIndex(-1)
Any variation of $ UserProfileService.GetUserProfileBy* produces the same error.
Has anyone encountered this, or have any suggestions?
Thanks!