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:MyFoldersitemap.xml”);
$site = Get-SPSite “http://server:80”;
$site.RootWeb.Files.Add(“sitemap.xml”, $fileBytes, $true);

Leave a Comment