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..."

Comments

Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX