Audiences in SharePoint 2010: Get a hold on them via PowerShell

Audiences are part of a User Profile service application and they are used for content targeting in the SharePoint platform. By using them you can show WebPart just for a group of users (the audience). On the administrative level via the Central Administration users can be directed to their MySite home location via the 'My Site Host Location'. This is extremely useful in a global SharePoint architecture with regional SharePoint farms and users redirected to their regional My Site host.

Please find detailed information regarding the content targeting at https://technet.microsoft.com/en-us/library/cc261958.aspx and the 'My Site Host' at https://technet.microsoft.com/en-us/library/cc263115(office.12).aspx.

In the following I would like to show a couple of PowerShell commands with which you can ge a hold on the audiences.

In SharePoint 2010 there is a AudienceManager object as part of the 'Audience Namespace' represents the entry point to the Audience feature in SharePoint 2010.

1. First you have to create an SPSite object

$SPSite = new-object Microsoft.SharePoint.SPSite(https://...)

2. Then you have to set up the server context

$srvCtx = [Microsoft.Office.Server.ServerContext]::GetContext($SPSite)

3. Finally we are ready to create the corresponding AudienceManager object

$auManager= new-object Microsoft.Office.Server.Audience.AudienceManager($srvContext)

4. Now we are ready to get a list of all audiences

$auManager.Audiences | fl

Comments

  • Anonymous
    January 01, 2003
    Many thanks and changed accordingly.

  • Anonymous
    July 20, 2011
    Method in step 2 is GetContext as opposed to GetContent

  • Anonymous
    October 10, 2011
    The comment has been removed

  • Anonymous
    October 12, 2011
    It should really be: $auManager= new-object Microsoft.Office.Server.Audience.AudienceManager($srvCtx)