Skip to content

Instantly share code, notes, and snippets.

@jeffpatton1971
Created April 24, 2014 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffpatton1971/11264640 to your computer and use it in GitHub Desktop.
Save jeffpatton1971/11264640 to your computer and use it in GitHub Desktop.
Create Sharepoint Online Site
#
# Need this
# http://www.microsoft.com/en-ie/download/confirmation.aspx?id=35585
#
Add-Type -Path "c:\folder\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\folder\Microsoft.SharePoint.Client.Runtime.dll"
$siteUrl = "https://tenant.sharepoint.com/sites/things"
$credentials = (Get-Credential)
$ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$SharepointCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credentials.UserName, $credentials.GetNetworkCredential().Password)
$ClientContext.Credentials = $SharepointCredentials
$webCreationInformation = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$webCreationInformation.Url = "site1"
$webCreationInformation.Title = "Site 1"
$webCreationInformation.WebTemplate = "STS#0"
$newSite = $ctx.Web.Webs.Add($webCreationInformation)
$ClientContext.Load($newSite)
$ClientContext.ExecuteQuery()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment