This cmdlet sets a view to hidden.
Parameters: SiteCollection url.
Edit $listUrl and $viewUrl to your own values.
Parameters: SiteCollection url.
Edit $listUrl and $viewUrl to your own values.
param([string]$url) param([string]$url) [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") function Get-SPSite([string]$url) { New-Object Microsoft.SharePoint.SPSite($url) } function Hide([string]$url) { $SPSite = Get-SPSite $url $listUrl = "/Lists/Tasks"; $viewUrl = "Lists/Tasks/byowner.aspx"; foreach($oWeb in $SPSite.AllWebs) { Write-Host "###############################"; Write-Host "Web: " $oWeb.Url; [Microsoft.SharePoint.SPList]$list = $null; [Microsoft.SharePoint.SPView]$spView = $null; try { $list = $oWeb.GetList("$($oWeb.Url)$($listUrl)"); } catch [Exception] { Write-Host "The list does not exist" -foreground red; $oWeb.Dispose(); continue; } try { $spView = $oWeb.GetViewFromUrl($viewUrl); $spView.Hidden = $true; $spView.Update(); } catch [Exception] { Write-Host "The view does not exist" -foreground red; $oWeb.Dispose(); continue; } Write-Host "View: " $spView.Title -foreground blue; Write-Host "View hidden: " $spView.Hidden -foreground blue; Write-Host "ParentList: " $spView.ParentList -foreground green; $oWeb.Dispose(); Write-Host "############ ###################"; } $SPSite.Dispose() } Hide -url $url
Comments
Post a Comment