如何使用 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
}
}