create a sharepoint webpart page using Powershell
I have to create a sharepoint webpart page using Powershell scripts. Is there any way to do that ?
November 22nd, 2011 5:50am

Hi, You achieve with powershell below: $spWeb = Get-SPWeb -Identity "your site url" $pubWeb =[Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb) # Create blank web part page $pl = $pubWeb.GetAvailablePageLayouts() | Where { $_.Name -eq "BlankWebPartPage.aspx" } #you may change "BlankWebPartPage.aspx" to your custom page layout file name $newPage = $pubWeb.AddPublishingPage("your file name.aspx", $pl) #filename need end with .aspx extension $newPage.Update() # Check-in and publish page $newPage.CheckIn("") $newPage.ListItem.File.Publish("") $spWeb.Dispose() Hope helps. Cheers
Free Windows Admin Tool Kit Click here and download it now
November 22nd, 2011 8:46am

hi, Thanks for reply, 1 more thing I have to use a Layout Template for that WebPart Page from the SharePoint specified layout templates. I have to use "Left column, Header, Footer, Top Row, 3 columns" layout template, where can i specify to use that template.
November 22nd, 2011 9:06am

for the line $pl = $pubWeb.GetAvailablePageLayouts() | Where { $_.Name -eq "BlankWebPartPage.aspx" } #you may change "BlankWebPartPage.aspx" to your custom Change to your own page layout :)
Free Windows Admin Tool Kit Click here and download it now
November 22nd, 2011 5:36pm

Hi cchitsiang, Any Ideas about how can we create an aspx page / blank webpart page from powershell for sharepoint foundation 2010, since sharepoiunt foundation 2010 won't be having the publishing feature and the microsoft.sharepoint.publishing dll. Your above code does not run in powershell if i am working in foundation 2010. So, How would you achieve this task ? I am a newbie to 2010 so, please any help would be really needful ?? Thanks!!!!!!!!
May 17th, 2012 1:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics