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: 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()