Through this article, it will be easy to approve master pages and pagelayouts that you are going to upload. It will save the time of approving each item.#Add the Sharepoint powershell Snap In#Call PowershellSnap in FunctionAdd-PSSnapin Microsoft.SharePoint.PowershellSet-ExecutionPolicy RemoteSigned -ErrorAction SilentlyContinue -ErrorVariable excPolicyErr $ExecutionPolicy = Get-ExecutionPolicyif($excPolicyErr){Write-Host "$excPolicyErr"}Write-Host "My 2010 Powershell Script" $site = Get-SPSite -Identity "http://sharepointHome:2010"$SPWeb = Get-SPWeb "http://sharepointHome:2010/"$List = $SPWeb.Lists["Master Page Gallery"];for($i=0;$i -le $List.Folders.count;$i++){if(($List.Folders[$i].folder.name -eq "MyCustomMasterPage") -or ($List.Folders[$i].folder.name -eq "MyCustomPageLayouts")){$univadisPagesFolder = $SPWeb.GetFolder($List.Folders[$i].Folder.Url);$univadisPages = $univadisPagesFolder.Files;foreach ($univadisPage in $univadisPages){$lstItem = $univadisPage.Item;if($lstItem.ModerationInformation){if ($lstItem.ModerationInformation.Status -eq [Microsoft.SharePoint.SPModerationStatusType]::Pending){$strStatus= [Microsoft.SharePoint.SPModerationStatusType]::Approved; $lstItem.ModerationInformation.Status = $strStatus;$lstItem.Update();$univadisPage.Approve("Approved");$univadisPage.Update(); Write-host "Approved:" $univadisPage.Name} }} } }$List.Update()Save the file with extension .ps1 and call the file using a bat file.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: