Guest User

Untitled

a guest
Oct 17th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. ##Variables for Processing
  2. $SiteUrl = "https://lz.sharepoint.com/sites/lz"
  3. $UserName="lz@lz.onmicrosoft.com"
  4. $Password ="****"
  5. $libraryName="DL"
  6.  
  7. Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll"
  8. Add-Type -Path "c:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  9.  
  10. #Setup Credentials to connect
  11. $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
  12. #Setup the context
  13. $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
  14. $Ctx.Credentials = $Credentials
  15. $Web = $Ctx.web
  16.  
  17. #Get the List
  18. $List = $Ctx.Web.Lists.GetByTitle($libraryName)
  19. $Ctx.Load($List)
  20. $Ctx.ExecuteQuery()
  21.  
  22. #Get All List items
  23. $ListItemsCAML = New-Object Microsoft.SharePoint.Client.CamlQuery
  24. $ListItemsCAML.ViewXml = "<View Scope='RecursiveAll'></View>"
  25. $ListItems = $List.GetItems($ListItemsCAML)
  26. $Ctx.Load($ListItems)
  27. $Ctx.ExecuteQuery()
  28.  
  29. Write-host "Total Items Found:"$List.ItemCount
  30. #Iterate through each item and update
  31. Foreach ($ListItem in $ListItems)
  32. {
  33. #Set New value for List column
  34. $ListItem["Archive"] = $false
  35. $ListItem.Update()
  36. $Ctx.ExecuteQuery()
  37. }
  38. Write-host "All Items in the Library: $libraryName Updated Successfully!" -ForegroundColor Green
Add Comment
Please, Sign In to add comment