Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. $web = get-spweb "http://www.questionstackexchange.fr/subsite";
  2. $list = $web.lists["MyLittleList"];
  3. $files = $list.rootfolder.files;
  4.  
  5. $form = $list.RootFolder.files | ?{$_.url -match "dispform.aspx"};
  6. $form.delete();
  7. $list.update();
  8.  
  9. $dispformurl = $list.RootFolder.ServerRelativeUrl + "/Dispform.aspx";
  10. $dispform = $files.add($dispformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage);
  11. $wpm = $dispform.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);
  12. $lfw = new-object ([Microsoft.SharePoint.WebPartPages.ListFormwebpart]);
  13. $lfw2 = new-object ([Microsoft.SharePoint.WebPartPages.ListViewWebPart]);
  14. $ilist = [Microsoft.SharePoint.WebPartPages.IListWebPart]($lfw);
  15. $ilist2 = [Microsoft.SharePoint.WebPartPages.IListWebPart]($lfw2);
  16. $ilist.ListId = $list.id;
  17. $ilist2.ListId = "B4A7D0D0-221D-492C-B6E6-A5D758EDD3F2";
  18. $ilist.PageType = [Microsoft.SharePoint.PAGETYPE]::PAGE_DISPLAYFORM;
  19. $ilist2.PageType = [Microsoft.SharePoint.PAGETYPE]::PAGE_DISPLAYFORM;
  20. $wpm.AddWebPart($lfw, "Main", 1) ;
  21. $wpm.AddWebPart($lfw2, "Header", 1) ;
  22. $list.DefaultDisplayFormUrl = $dispformurl;
  23. $list.update();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement