Friday, 5 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 = [system.io.file]::ReadAllBytes("D:\MyFolder\sitemap.xml");
$site = Get-SPSite "http://server:80";
$site.RootWeb.Files.Add("sitemap.xml", $fileBytes, $true);

No comments:

Post a Comment