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

Requirement: PowerShell to get and set 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="http://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 yes/no field from the given list.

Update Yes/No Field in SharePoint List using PowerShell
PowerShell to Update Yes No field SharePoint list programmatically
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set variables
$WebURL="http://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()
PowerShell to Get-Set "Yes/No (Check box)" Field Value in SharePoint PowerShell to Get-Set "Yes/No (Check box)" Field Value in SharePoint Reviewed by Salaudeen Rajack on January 05, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.