Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.dll"
  2. Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  3.  
  4. $siteUrl = “https://tenant.sharepoint.com/sites/mysitecollection”
  5. $username = "username@tenant.onmicrosoft.com"
  6. $password = Read-Host -Prompt "Enter password" -AsSecureString
  7. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
  8. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
  9. $ctx.Credentials = $credentials
  10.  
  11. $webCreationInformation = New-Object Microsoft.SharePoint.Client.WebCreationInformation
  12. $webCreationInformation.Url = "site1"
  13. $webCreationInformation.Title = "Site 1"
  14. $webCreationInformation.WebTemplate = "STS#0"
  15. $newWeb = $ctx.Web.Webs.Add($webCreationInformation)
  16.  
  17. $ctx.Load($newWeb)
  18. $ctx.ExecuteQuery()
  19. Write-Host "Title" $newWeb.Title
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement