Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $web = get-spweb "http://www.questionstackexchange.fr/subsite";
- $list = $web.lists["MyLittleList"];
- $files = $list.rootfolder.files;
- $form = $list.RootFolder.files | ?{$_.url -match "dispform.aspx"};
- $form.delete();
- $list.update();
- $dispformurl = $list.RootFolder.ServerRelativeUrl + "/Dispform.aspx";
- $dispform = $files.add($dispformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage);
- $wpm = $dispform.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);
- $lfw = new-object ([Microsoft.SharePoint.WebPartPages.ListFormwebpart]);
- $lfw2 = new-object ([Microsoft.SharePoint.WebPartPages.ListViewWebPart]);
- $ilist = [Microsoft.SharePoint.WebPartPages.IListWebPart]($lfw);
- $ilist2 = [Microsoft.SharePoint.WebPartPages.IListWebPart]($lfw2);
- $ilist.ListId = $list.id;
- $ilist2.ListId = "B4A7D0D0-221D-492C-B6E6-A5D758EDD3F2";
- $ilist.PageType = [Microsoft.SharePoint.PAGETYPE]::PAGE_DISPLAYFORM;
- $ilist2.PageType = [Microsoft.SharePoint.PAGETYPE]::PAGE_DISPLAYFORM;
- $wpm.AddWebPart($lfw, "Main", 1) ;
- $wpm.AddWebPart($lfw2, "Header", 1) ;
- $list.DefaultDisplayFormUrl = $dispformurl;
- $list.update();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement