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

[玩转系统] 在 PowerShell 中从 SharePoint 视图获取列表项

作者:精品下载站 日期:2024-12-14 13:46:07 浏览:10 分类:玩电脑

在 PowerShell 中从 SharePoint 视图获取列表项


要求:从 PowerShell 中的 SharePoint 视图获取所有列表项

[玩转系统] 在 PowerShell 中从 SharePoint 视图获取列表项

PowerShell 在 SharePoint 中获取项目 列表视图

使用 SharePoint 时,有时需要从视图中获取项目列表,而不是获取列表中的所有项目。无论您是要导出数据还是只是需要某种方式自动从 SharePoint 视图获取数据以用于报告或其他目的,PowerShell 都是您的答案!在这篇文章中,我们将了解如何使用 PowerShell 从 SharePoint 列表视图中获取项目。

以下是从 SharePoint 视图获取列表项的 PowerShell 脚本示例:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables
$SiteUrl="https://intranet.crescent.com" 
$ListName = "Invoice"
$ViewName = "2014 Invoice"

#Get Web and List objects
$web = Get-SPWeb $SiteURL
$list = $web.Lists[$ListName]

#Get the View
$view = $list.Views[$ViewName]

#Get All Items from the View
$items = $list.GetItems($view)

foreach($item in $items)
{
    write-host $item["Title"]
}

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

取消回复欢迎 发表评论:

关灯