One of the requirements of this article was to replace the current webpart from my SharePoint webpage that was bringing about numerous issues with execution. This web part was accessible in various content pages. So one of the choices accessible to us was to compose a PowerShell script to add another web part to various substance pages.

SharePoint-2013-Hosting

The article will describes how to add a webpart to a SharePoint page using a PowerShell script. To include the web part we will require a web part definition document to be accessible on the record framework so we can add it to the webpart exhibition, import it and include it utilizing the WebPartManager class.

Now, consider we have to add the webpart to the MyWPPage.aspx page from the page library of the web MyWeb. We have to get a distributed web instance from web instance and set the allow unsafe updates to true as follows:

Get the distributed web occasion and set the allow unsafe update property to true.

And now, get the pages library and find the list item with the following code:

Get the document from listitem, watch that if this page is looked at to an other user or the same user and if the same user then publish and then check out the page.

From the local file system, get the file stream and import it using the webpart manager as follows:

Check in the page & clean up the instances.

Hope it works for you!

SharePoint 2013 Hosting Recommendation

HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options

recommended windows hosting