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

[玩转系统] 如何使用 PowerShell 获取 SharePoint 站点中的所有列表?

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

如何使用 PowerShell 获取 SharePoint 站点中的所有列表?


使用 PowerShell 获取 SharePoint 网站中的所有列表:

管理列表和库是任何 SharePoint 管理员工作的重要组成部分。如果您需要获取特定站点上所有列表的列表该怎么办?在这篇博文中,我们将介绍如何使用 PowerShell 从 SharePoint 网站获取所有列表。可以根据您的需要修改此脚本以包含其他过滤或操作。

要使用 PowerShell 获取所有 SharePoint 列表,请使用以下脚本:


Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

#Configuration Variables for Web URL
$WebURL ="https://sharepoint.company.com/"

#Get the site
$Web = Get-SPWeb $WebURL

#Get all sharepoint lists by using powershell 
$ListCollection = $Web.Lists

#sharepoint powershell loop through all lists
Foreach($list in $ListCollection)
{
   #get list details 
   Write-host $List.Title - $list.ItemCount - $List.Author.Name
}

使用 PowerShell 获取 SharePoint 中所有列表的一行脚本:


(Get-SPweb "https://sharepoint.company.com/").Lists | ForEach-Object { Write-Host $_.Title}

SharePoint PowerShell 获取网站集中的所有列表:

下面是用于获取网站集中所有列表的 PowerShell。


Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

#Configuration Variables for Site Collection URL
$SiteURL ="https://sharepoint.company.com/sites/Sales"
$Site = Get-SPSite $SiteURL

#Iterate through each web in the site collection
foreach($Web in $Site.AllWebs)
{
    Write-Host $Web.Url -ForegroundColor DarkRed
 
    #Loop through each List in the site
    foreach($List in $Web.Lists)
    {
         Write-Host $list.Title -ForegroundColor Blue
    }
}

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

取消回复欢迎 发表评论:

关灯