When administering a large SharePoint 2010 deployment, there are times when you may need to take an inventory of the user profiles in your profile store – perhaps to find users with a common property or characteristic, run some comparisons of your SharePoint profiles to Active Directory, or do some other administrative task.
Here’s a simple PowerShell script that enumerates all user profiles in the context of your SharePoint site and emits some of their properties, such as Display Name, AccountName, and workEmail.
Note: The account which will be executing this script needs to have Full Control access to the User Profile Service application. Follow these two steps:
1) Go to Central Administration > Manage service applications > select (highlight) your user profile application > click on Administrators button on the ribbon and add your account.
2) Go to Central Administration > Manage service applications > select (highlight) your user profile application > click on Permissions button on the ribbon and add your account with Full Control – make sure to check the “Full Control” checkbox!
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") # Enter your SharePoint site URL here... $site = new-object Microsoft.SharePoint.SPSite("http://..."); $ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site); $ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext) $AllProfiles = $ProfileManager.GetEnumerator() write-host "Display Name ; AccountName ; Email ; " foreach($profile in $AllProfiles) { $DisplayName = $profile.DisplayName $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value $workEmail = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::workEmail].Value write-host $DisplayName, ";", $AccountName, ";" , $workEmail, ";" } write-host "Finished." $site.Dispose()
A full list of SP 2010 user profile properties is available on MSDN here:
http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.propertyconstants_members.aspx