Category Archives: SharePoint

WebPart Targeting with Powershell

WebPart Targeting with Powershell in SharePoint 2013

$web = Get-SPWeb "http://sharepoint/Page2";
$sharepointGroups = ';;Group1,Group2';
$webPath = "pages/yourpage.aspx";
$webPM = $web.GetLimitedWebPartManager($webPath, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);
$webParts = $webPM.WebParts;
$myWebPart = $webParts | where { $_.Title -match "Web Part name" };
$myWebPart.AuthorizationFilter = [string]"$sharepointGroups";
$webPM.SaveChanges($myWebPart);
$web.Dispose();
Advertisements

Rename Quick Launch Item

Rename Quick Launch Item with Powershell in SharePoint 2013

$web = Get-SPWeb "http://sharepoint/Page1";
$quickLaunchNav = $web.Navigation.QuickLaunch;
$item2Rename = $quickLaunchNav | where { $_.Title -match "itemName" };
$item2Rename.Title = "NewItemName";
$item2Rename.Update();
$web.Dispose();