I recently had a need for a PowerShell script that would enumerate the fields on a user profile and thought I’d share it as well as point out some minor hurdles I encountered when I tried to run the script. Its important to note this script is for SharePoint 2010. There’s been some pretty major changes to the User Profile Service so I don’t expect this script to work with WSS 3.0 or MOSS 2007.
I recently discovered the magic that is Amazon S3 so you can download the script from https://s3.amazonaws.com/mymemorysucks.com/userprofilepropertiesenum/userprofilepropertiesenum.ps1 . To use it, its just a matter of specifying the “-siteaddress” parameter on the command line like so.
Hopefully the next screen you will see is the following. As you can see in the screenshot the script currently just outputs the ‘DisplayName’ and ‘Name’ of the user profile property.
If you encounter the following error instead then it possibly means that the account you’re running the command line under doesn’t have ENOUGH permissions to access the User Profile Service Application. I use the word ‘enough’ because like me the first time, you’re probably thinking that running under a farm administrator account should be enough but there’s some extra permissions you need to set for your farm administrator account.
First off, go to the ‘Manage Service Applications’ page under ‘Application Management’. You first need to select the ‘User Profile Service Application’ and then you’ll have access to the ‘Permissions’ tab along the ribbon as shown in the screenshot below.
You will need to make sure that the account you’re using is granted ‘Full Control’ under the ‘Permissions’ tab as shown in the screenshot below.
Hopefully after granting the account ‘Full Control’ you should be able to execute the script.