Hi,
Can anyone pls help , how to set the target audience of a Summary links web part using powershell.
I am having code for fidning the summary link web parts within a page. but am stuck with how to set the audience targeting - i want to set this to only a SPGroup -say in my case a spgroup called "DCCGroup" .
i got help from srinu tamada's blog :
http://srinutamada1.wordpress.com/2012/10/12/reading-summary-links-using-powershell/#comment-954
$pages = $web.Lists[“Pages”];
foreach($page in $pages.Items)
{
if($page -eq $null)
{
continue;
}
if ($null -eq [System.Web.HttpContext]::Current)
{
$sw = New-Object System.IO.StringWriter
$resp = New-Object System.Web.HttpResponse $sw
$req = New-Object System.Web.HttpRequest“”, $web.Url, “”
$htc = New-Object System.Web.HttpContext $req, $resp
$htc.Items[“HttpHandlerSPWeb”] = $web -as [Microsoft.SharePoint.SPweb]
[System.Web.HttpContext]::Current = $htc
}
$webPartCollection = $page.Web.GetWebPartCollection($page.Url,[Microsoft.SharePoint.WebPartPages.Storage]::Shared)
foreach($wp in $webPartCollection)
{
$webpart = $wp -as [Microsoft.SharePoint.WebPartPages.WebPart]
if ($webpart.GetType().Name -eq ‘SummaryLinkWebPart’)
{
Write-Output $page.url
Write-Output “Summary Links:”
$sumWP = $webpart -as [Microsoft.SharePoint.Publishing.WebControls.SummaryLinkWebPart]
$sumWP.SummaryLinks
foreach ($summarylink in $sumWP.SummaryLinkValue.SummaryLinks)
{
Write-Output $summarylink.LinkUrl
}
}
}
}
but once i get the summary links web part how to implement audience targetting. i am trying o do with powershell..
help is appreciated!
Das