Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Salvete! Is it possible to add a webpart to a Wiki Home Page via Powershell? I have 100 sites for which I need to add a web-part to their home-pages. I know this is easily possible with normal web-part pages, but how about a wiki-home page?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Yes, it's possible. I had a blog post on this very topic, but the blog site has since been deactivated. Basically you do it like you would add a web part to any other Web Part Page. When it's time to specify the zone, use the "wpz" zone. Also, you need to add some markup to the Page's "WikiField" that resembles this (substituting your Web Part ID Guid where appropriate):

<div class="ms-rtestate-read ms-rte-wpbox">
  <div class="ms-rtestate-read {webpart ID guid}"
       id="div_{webpart ID guid}">
  <div class="ms-rtestate-read"
       id="vid_{webpart ID guid}"
       style="display: none">

This posting was similar to the content I presented in my (now deleted) posting: http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/

share|improve this answer
Ah, that would mean that if I have 100 sites with wiki home-pages, that I would have to manually edit every one of them ahead of time, right? However, this is a good answer. –  BGM Jul 12 '12 at 2:35
No, you could write some powershell to manipulate the page. The basic structure would be to loop through each site, get a reference to the SPFile representing the home page, get a reference to the SPLimitedWebPartManager, then add the web part, get a reference to the web part's ID, then update the WikiField property of the SPFile's ListItem with the markup showed. Where it might get tricky is identifying where to insert the markup. –  Brian Jul 12 '12 at 2:42
In a normal web part page, you identify the web part order, in the WikiField you must put the markup for the web part (shown in answer I provided), in with the rest of the markup (and web parts) in the page. So if each home page has different markup, the best you may be able to do is insert it at the top or bottom of the markup. If each home page has the same markup (i.e. hasn't change since provisioned), you could locate the spot in markup using string manipulation to insert the web part markup. –  Brian Jul 12 '12 at 2:44
Thank you for your comments. Too bad there's no way to contact you via email... I'd like to get your help on some other things... –  BGM Jul 12 '12 at 2:59
Best thing is to post here so the rest of the folks can get access to your questions and you can gain a wide variety of folks responding with (usually) good > great answers. SharePoint is a large platform, there is something to learn new every day with it, despite how long you've been working with it. –  Brian Jul 12 '12 at 11:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.