As SP2016 farm administrator, I am trying to work on user profile with PowerShell. Found several examples that use

$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) 

But when doing for each on the enumerator, I get the error:

UserProfileDBCache_WCFLogging :: ProfileDBCacheServiceClient.GetUserData threw exception: Access is denied.

I also added myself to the service with full control and I am SysAdmin on the SQL instance.

2 Answers 2


Access denied denote to a permission issue, Meanwhile, you are using a user as a farm admin with sysadmin as server role,So my suggestion is to:

  • Make sure that you are running the PowerShell with the farm account (the service account used to configure SharePoint)

  • During provisioning UPS, the farm account must be added to local administrator group.

Note: After adding the farm account to local administrator group, you must restart the SharePoint 2013 Timer service or restart the server.

  • The service account of UPS has a full control permission in the application service settings.
  • Thank you M.Qassas.! Running as the service account did the trick. Whish it was more straight forward.
    – Ofer Gal
    Commented Feb 19, 2017 at 23:33
  • just Learnt to upvote :-)
    – Ofer Gal
    Commented Feb 22, 2017 at 0:12
  1. Navigate to the central admin web app
  2. Click on Manage Service Application
  3. Click on the UserProfileService Application
  4. On the top ribbon, click on the Administrator and add yourself with Full Control.
  5. Also on the Top Ribbon, click on Permissions, add yourself, and give Full control here as well. If this step is not completed, you will still be receiving Access denied error.
  • and no service need to be restarted in this answer :)
    – Popkornak
    Commented Jan 19, 2022 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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