Friday, 3 July 2015

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:\myfolder\page1.html");
$site = Get-SPSite "http://server";
$site.RootWeb.Files.Add("page1.html", $fileBytes, $true);
Write-Host "Done..."

No comments:

Post a Comment