Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  $siteURL = "https://globomanticsorg.sharepoint.com"
  2.     $adminUrl = "https://globomanticsorg-admin.sharepoint.com"
  3.     $userName = "vlad@globomantics.org"
  4.      
  5.     # Let the user fill in their password in the PowerShell window
  6.     $password = Read-Host "Please enter the password for $($userName)" -AsSecureString
  7.      
  8.     # set SharePoint Online credentials
  9.     $SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
  10.          
  11.     # Creating client context object
  12.     $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
  13.     $context.credentials = $SPOCredentials
  14.     $web = $context.Web
  15.     $templates = $context.Site.GetCustomListTemplates($web)
  16.     $context.Load($templates)
  17.     $context.ExecuteQuery()
  18.     $template = $templates | Where-Object{ $_.Name -eq "UserswithContent" }
  19.    
  20.     $lci = New-Object Microsoft.SharePoint.Client.ListCreationInformation
  21.     $lci.Title = "pstest1"
  22.     $lci.TemplateType = $template.ListTemplateTypeKind
  23.  
  24.     $lists = $context.Web.Lists;
  25.     $context.Load($lists);
  26.     $context.ExecuteQuery();
  27.  
  28.     $list = $lists.Add($lci)
  29.     $list.Update()
  30.     $context.ExecuteQuery()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement