Tuesday 7 January 2014

Delete Custom Master Page using PowerShell



cls

 # Add the Powershell snapin,
     
       if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
       {
           Add-PSSnapin "Microsoft.SharePoint.PowerShell"
       }

# Get the Name of the Website where we need to delete the Custom Master Page from Master Page Library.

        $web=Get-SPWeb "http://sedwdevrtm:22222/sites/Learning/"

 # Note assumption that seatle_manju.master is not a default master page , if its a default master then we can't delete it

        $lib=$web.GetFolder("_catalogs/masterpage").Files["seatle_manju.master"];

        Write-Host "Current library is " $lib

        $lib.Delete();

        $web.Dispose();




No comments:

Post a Comment