Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PowerShell WebParts , +
Hello everybody.
 
I am trying to create a regular web part page with powershell and I am not able to do it. There is no information in google about the error I get:
$spWeb = Get-SPWeb -Identity "http://server/site"
$pubWeb =[Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb)
$pl = $pubWeb.GetAvailablePageLayouts()
Exception calling "GetAvailablePageLayouts" with "0" argument(s): "Object reference not set to an instance of an object."
At line:1 char:38
+ $pl = $pubWeb.GetAvailablePageLayouts <<<< ()
    + CategoryInfo          : NotSpecified: (: ) [ ], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
The error occurs when executing GetAvailablePageLayouts().
 
Any clue? Thank you.
Posted 22-Jan-13 4:47am
Edited 22-Jan-13 5:16am
496.8K
v2
Comments
Sandeep Mewara at 22-Jan-13 11:18am
   
Does this expect parameters: GetAvailablePageLayouts ?
 
is #pubWeb not null? Debug and see.
garfield185 at 22-Jan-13 11:20am
   
Can have, or not any parameters. Should work without any paramenters.
And, after doing $pubweb I receive
 
IsAllowingAllWebTemplates : True
IsAllowingAllPageLayouts : True
IsInheritingAvailableWebTemplates : False
IsInheritingAvailablePageLayouts : False
IsInheritingDefaultPageLayout : False
IsInheritingNewPageUrlToken : False
DefaultPageLayout :
NewPageUrlToken : NewPage
Web : Home
IsRoot : False
....
 
So I can confirm it is not null.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 443
1 Sergey Alexandrovich Kryukov 197
2 PhilLenoir 145
3 RyanDev 125
4 Richard Deeming 120
0 Sergey Alexandrovich Kryukov 6,415
1 OriginalGriff 5,856
2 CPallini 2,473
3 Richard MacCutchan 1,667
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100