Powershell Command to add a file to root of SharePoint

This blog will explain about adding a file to SharePoint root.
Generally sharepoint structure is http://server/pages/page1.html
Suppose you need to add a file in root which should access by http://server/page1.html

This can be done by powershell command.

Write-Host “Powershell started…..”
Add-PSSnapIn Microsoft.SharePoint.PowerShell
$fileBytes = [system.io.file]::ReadAllBytes(“C:myfolderpage1.html”);
$site = Get-SPSite “http://server”;
$site.RootWeb.Files.Add(“page1.html“, $fileBytes, $true);
Write-Host “Done…”

Leave a Comment

RSS
YouTube
YouTube
Instagram