Error: Update-SPProfilePhotoStore : Object reference not set to an instance of an object
Posted
Wednesday, May 2, 2012 5:48 PM
by
CoreyRoth
I like blogging about errors and their resolutions. Sometimes the answer is simple, but I think there is a lot of value in posting the details of an error so that users can find answers in the search engines. After doing a My Sites upgrade from SharePoint 2007, you will have a whole heap of user photos that you need to beat into submission. This command goes through all of the existing user photos and creates thumbnails. This is often useful when a user has uploaded a giant image of themselves and you need to fix it. To do this, you may be familiar with the PowerShell command Update-SPProfilePhotoStore. You call it by passing the URL to your My Sites host.
Update-SPProfilePhotoStore http://mysitehosturl
If you don’t have the right permissions, you will find yourself with the following error:
Update-SPProfilePhotoStore : Object reference not set to an instance of an object.
At line:1 char:27
+ Update-SPProfilePhotoStore <<<< -MySiteHostLocation http://mysites
+ CategoryInfo : InvalidData: (Microsoft.Offic...ofilePhotoStore:
SPCmdletUserProfilePhotoStore) [Update-SPProfilePhotoStore], NullReference
Exception
+ FullyQualifiedErrorId : Microsoft.Office.Server.UserProfiles.PowerShell.
SPCmdletUserProfilePhotoStore
Now clearly to you that means you don’t have the right permissions, correct? Of course not. To run this command, you need the permissions as defined in this post on MSDN blogs. Now, you could take the easy way out and just run PowerShell as the farm account. However, I know you know better. Just go set up the right permissions and you’ll be set. The post on MSDN summarizes them as follows:
- Go to Service Applications, select your User Profile Service Application, and then click Permissions. Add your account and check the Full Control checkbox.
- Select the User Profile Service Application, and then click the Administrators button. Add your account there and check the Manage Profiles checkbox and nothing else.
Note that you can add groups on the Administrators section but you can’t on the Permissions section. Once you do that, run PowerShell with the Run as Administrator option and run Update-SPProfile again. It should execute without an object reference error.