当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] PowerShell 在 SharePoint 中获取设置“是/否(复选框)”字段值

作者:精品下载站 日期:2024-12-14 21:05:51 浏览:14 分类:玩电脑

PowerShell 在 SharePoint 中获取设置“是/否(复选框)”字段值


要求:PowerShell 获取或设置 SharePoint 中的“是/否”字段值。

[玩转系统] PowerShell 在 SharePoint 中获取设置“是/否(复选框)”字段值

SharePoint:使用 PowerShell 获取是/否字段值

以下是在 SharePoint 中以编程方式读取“是/否”字段的 PowerShell:


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]

这将从给定列表中获取是/否字段的值。

使用 PowerShell 更新 SharePoint 列表中的是/否字段

以下是用于以编程方式更新是否字段 SharePoint 列表的 PowerShell。


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

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯