Showing posts with label SharePoint how to hide Webpart using power shell script. Show all posts
Showing posts with label SharePoint how to hide Webpart using power shell script. Show all posts

Thursday, 3 July 2014

SharePoint how to hide Webpart using power shell script

$SPsite = Get-SPSite http:<MY-SHAREPOINT-SITE>/sites/admin/
$SPweb =  $SPsite.OpenWeb() 

# get the webpart manager for the page
$webpartmanager = $SPweb.GetLimitedWebPartManager(($SPweb.Url + "default.aspx"),  [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)   


For($i=0;$i -lt $webpartmanager.WebParts.Count;$i++)  

 {  
#Check for particular web part
if($webpartmanager.WebParts[$i].title -eq "Task")
  {  
       $webpartmanager.WebParts[$i].Hidden=true;
       break;

  }
} 

$SPweb.Update();


$SPweb.Dispose();