ค้นหาเว็บไซต์

PowerShell เพื่อรับการตั้งค่าฟิลด์ "ใช่/ไม่ใช่ (กล่องกาเครื่องหมาย)" ใน SharePoint


ความต้องการ: PowerShell เพื่อรับหรือตั้งค่าฟิลด์ใช่/ไม่ใช่ใน SharePoint

SharePoint: รับค่าฟิลด์ใช่/ไม่ใช่โดยใช้ PowerShell

นี่คือ PowerShell สำหรับอ่านฟิลด์ใช่/ไม่ใช่โดยทางโปรแกรมใน 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]

สิ่งนี้จะได้รับค่าของเขตข้อมูลใช่/ไม่ใช่จากรายการที่กำหนด

อัปเดตฟิลด์ใช่/ไม่ใช่ในรายการ SharePoint โดยใช้ PowerShell

นี่คือ PowerShell เพื่ออัปเดตรายการ SharePoint ของฟิลด์ใช่ไม่ใช่โดยทางโปรแกรม


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

บทความที่เกี่ยวข้อง