Monday, May 14, 2012

Compiling all audiences

I have a Powershell script that adds users and wanted it to also compile audiences. I thought this would have been under on of the UserProfileManager or the UserProfileConfigManager classes. However, it appears that it is only available under the RunAudienceJob static member of the Microsoft.Office.Server.Audience class. Fortunately, it is fairly straightforward to execute:

$applicationId = (Get-SPServiceApplication -Name 'User Profile Service Application').Id
$AUDIENCEJOB_START = '1'  
$AUDIENCEJOB_INCREMENTAL = '0'  
[Microsoft.Office.Server.Audience.AudienceJob]::RunAudienceJob(@($applicationId, $AUDIENCEJOB_START, $AUDIENCEJOB_INCREMENTAL))

... with some inspiration from: SharePoint 2010 Compile All Audiences 

No comments:

Post a Comment