I am trying to create a PowerShell script/function that will iterate through all the Document libraries (and folders within them) to set a column value on every file on the SharePoint site.

The column is called Archive. It is a Yes/No Column. How do I set the column to No ($false in PowerShell, I believe)?

  • Was there a specific question?
    – Graham
    Oct 17, 2018 at 19:37
  • Sorry, I should have added that I am looking for a way to do this
    – TomB1
    Oct 18, 2018 at 10:48

1 Answer 1


The following PowerShell script for your reference.

##Variables for Processing
$SiteUrl = "https://lz.sharepoint.com/sites/lz"
$UserName="[email protected]"
$Password ="****"

Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" 
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
$Web = $Ctx.web

#Get the List   
$List = $Ctx.Web.Lists.GetByTitle($libraryName)

#Get All List items
$ListItemsCAML = New-Object Microsoft.SharePoint.Client.CamlQuery
$ListItemsCAML.ViewXml = "<View Scope='RecursiveAll'></View>"
$ListItems = $List.GetItems($ListItemsCAML)

Write-host "Total Items Found:"$List.ItemCount
#Iterate through each item and update
Foreach ($ListItem in $ListItems)
    #Set New value for List column
    $ListItem["Archive"] = $false
Write-host "All Items in the Library: $libraryName Updated Successfully!" -ForegroundColor Green 
  • Thanks, does this look in folders though?
    – TomB1
    Oct 18, 2018 at 10:49
  • Yes, using "RecursiveAll" to get all items contains the folders and items in folders.
    – LZ_MSFT
    Oct 19, 2018 at 1:10

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.