I needed to report on the usage count of particular UPS user properties such as Skills and Responsibilities. If you look at the property in Central Administration, you can see a usage count on the screen. This field is populated using an internal class so I needed to look for another way to do it. When looking, I found the following property:
Microsoft.Office.Server.UserProfiles.CoreProperty.UsageCount
However, when you go to use it, it does not return a value and you will find it is producing a SQL error. You can find all the ins and outs of the issue in this blog post:
http://pholpar.wordpress.com/2010/03/12/bug-in-the-usecount-property-of-the-coreproperty-class/
However, the resolution in this blog post is NOT supported by Microsoft as it requires modifying the SharePoint database. After a quick call with Microsoft, I learned you can use this method to get the count:
Microsoft.Office.Server.UserProfiles.UserProfileConfigManager.CountProfileswithProperty
Hopefully this will help someone else out who runs into this issue. Here is an example PowerShell script with the method used in it:
Add-Type -Path “c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Server.UserProfiles.dll”
$propertyName = “SPS-Skills”
$siteUrl = “http://dev”
$site = Get-SPSite $siteUrl
$context = Get-SPServiceContext $site
$upcm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
Write-Host $upcm.CountProfilesWithProperty($propertyName)
Pingback: Office server | Connectmyheart