Saturday, 6 June 2015

How to add file in root of a sharepoint web application?

SharePoint folder structures are different, generally pages will be available in Page library. What if a user wants to add a file in root of SharePoint web application.

Generally sitemap and robots files are added to root.
Below is the powershell command which can add file to root location.

$fileBytes = []::ReadAllBytes("D:\MyFolder\sitemap.xml");
$site = Get-SPSite "http://server:80";
$site.RootWeb.Files.Add("sitemap.xml", $fileBytes, $true);

No comments:

Post a Comment

Dear Readers, Please post your valuable feedback in the comment section if you like this blog or if you have any suggestions. I would love to hear the same from you. Thanks