Thursday, February 16, 2012

Access MasterPage catalog with Powershell

To acces the Masterpage catalog via Powershell, and then use it as a list the following script might help

if(-not(Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

clear
$siteUrl = "http://yourserver.com"

$masterPageCatalog = "_catalogs/masterPage"

$site = Get-SPSite $siteUrl

$rootWeb = $site.RootWeb;

$folder = $rootWeb.GetFolder($masterPageCatalog)

$masterPageCatList = $rootWeb.Lists[$folder.ParentListId]

#do some list operations on it


$rootWeb.Dispose()
$site.Dispose()

No comments:

Post a Comment