PowerShell to Get-Set “Yes/No (Check box)” Field Value in SharePoint

Requirement: PowerShell to get or set the Yes/No field value in SharePoint.

sharepoint powershell get set yes no field value

SharePoint: Get Yes/No Field Value using PowerShell

Here is the PowerShell to read Yes/No field programmatically in SharePoint:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set variables
$WebURL="https://intranet.crescent.com"
$ListName ="ProjectTemp"
$FieldName="IsActive" #Internal Name
$ListItemID="1"

#Get Web and List Objects
$Web = Get-SPWeb $WebURL
$List = $Web.Lists[$ListName]

#Get the List Item by ID
$ListItem = $List.GetItembyID($ListItemID)
 
#Get the Yes/No Field Value
$ListItem[$FieldName]

This gets the value of the yes/no field from the given list.

Update Yes/No Field in SharePoint List using PowerShell

Here is the PowerShell to Update the Yes No field SharePoint list programmatically.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set variables
$WebURL="https://intranet.crescent.com"
$ListName ="Projects"
$FieldName="IsActive" #Internal Name
$ListItemID="1"

#Get Web and List Objects
$Web = Get-SPWeb $WebURL
$List = $Web.Lists[$ListName]

#Get the List Item to update
$ListItem = $List.GetItembyID($ListItemID)

#Update the Yes/No Field Value
$ListItem[$FieldName] = $False
$ListItem.Update()

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *