Saturday 4 February 2017

How to Create a SharePoint Subsite using CSOM and Powershell in Sharepoint Online/SharePoint 2013/2016?

Hello SharePoint Folks,
In this blog,we will see CSOM code to create a SharePoint subsite in Office 365.
$Username = Read-Host -Prompt “Please enter your username”
$Password = Read-Host -Prompt “Please enter your password” -AsSecureString
$Site = “https://mysite.sharepoint.com”
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)
$Context.Credentials = $Creds
$WebCI = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$WebCI.WebTemplate = “STS#0”
$WebCI.Description = “My own SubSite”
$WebCI.Title = ” My Baby SubSite”
$WebCI.Url = “SubSite”
$WebCI.Language = “1033”
$SubWeb = $Context.Web.Webs.Add($WebCI)
$Context.ExecuteQuery()
Happy SharePoint :)

No comments:

Post a Comment