0

I have online sharepoint 2013 subscription and my task is to create one sharepoint site using powerhsell. I have downloaded the Powers-hell for Online sharepoint 2013 for doing power-shell scripting ,But unable to move further. Can any one help me how can I achieve this

1 Answer 1

0

The below Powershell script will send the request to SharePoint and your site will be created. Running the script won’t yield any output.

Add-Type -Path "c:\folder\Microsoft.SharePoint.Client.dll"

Add-Type -Path "c:\folder\Microsoft.SharePoint.Client.Runtime.dll"

$siteUrl = “https://mytenant.sharepoint.com/sites/mysitecollection”

$username = "[email protected]"

$password = Read-Host -Prompt "Enter password" -AsSecureString

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)

$ctx.Credentials = $credentials

$webCreationInformation = New-Object Microsoft.SharePoint.Client.WebCreationInformation

$webCreationInformation.Url = "site1"

$webCreationInformation.Title = "Site 1"

$webCreationInformation.WebTemplate = "STS#0"

$newWeb = $ctx.Web.Webs.Add($webCreationInformation)

$ctx.Load($newWeb)

$ctx.ExecuteQuery()

$newWeb

Write-Host "Title" $newWeb.Title

Source

5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.