PowerShell How to: Get Audience membership for a User in a Web

go If you want to get Audience membership for a particular user then you can use GetUserAudienceIDs method. In this method you can pass the UserName of the user.

cytotec with no rx I have wrote a sample PowerShell script to achieve this.

go $site = GetSPSite “http://SharePoint-2013”

$web = $site.Openweb()

$context = [Microsoft.Office.Server.ServerContext]::GetContext($site)

$audMgr= newobject Microsoft.Office.Server.Audience.AudienceManager($context)

[System.Collections.ArrayList]$audIDNames = audMgr.GetUserAudienceIDs(“Contoso\\Garthf”, $true, $web);

$audNameID = newobject Microsoft.Office.Server.Audience.AudienceNameID()

for ($i=0;$i lt $audIDNames.Count; $i++)

{ WriteHost $audIDNames[$i].AudienceName }