SharePoint Online: Lấy số lượng trang con trong mỗi tuyển tập trang
Yêu cầu: Tìm hiểu số lượng trang con trong mỗi tuyển tập trang trong SharePoint Online.
PowerShell để tìm tổng số trang con trong tuyển tập trang SharePoint Online
Làm thế nào để bạn biết có bao nhiêu site con trong một tuyển tập site? Bài đăng blog này sẽ chỉ cho bạn cách tìm số lượng trang con trong tuyển tập trang SharePoint Online.
#Parameters
$AdminCenterURL = "https://Crescent-admin.sharepoint.com"
$SiteURL = "https://Crescent.sharepoint.com/sites/Marketing"
#Connect to SharePoint Online
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)
#Get the Site
$Site = Get-SPOSite -Identity $SiteURL
#Get Total number of subsites
Write-host "Total Number of Subsites:" ($Site.WebsCount-1)
Thuộc tính “WebsCount” lấy tổng số trang web trên trang web, bao gồm cả RootWeb. Làm thế nào để có được tổng số trang con cho tất cả các trang trong SharePoint Online?
#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
$SitesData = @()
#Connect
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)
#Get All Site Collections
$Sites = Get-SPOSite -Limit All
#Loop through each site
ForEach($Site in $Sites)
{
#Get the Site
$Site = Get-SPOSite -Identity $Site
#Collect subsites data
$SitesData += New-Object PSObject -property $([ordered]@{
SiteName = $Site.Title
SiteURL = $Site.Url
Subsites = $Site.WebsCount-1
})
}
$SitesData
Tập lệnh này giúp bạn có được số lượng trang con trên tất cả các cấp độ của từng tuyển tập trang trong đối tượng thuê.
PnP PowerShell để lấy số lượng trang con trên mỗi tuyển tập trang
Lần này, hãy trích xuất số lượng trang con cho tất cả tuyển tập trang và xuất kết quả tìm kiếm sang CSV.
#Parameters
$SiteURL ="https://crescent-admin.sharepoint.com"
$CSVFile = "C:\Temp\SubsitesCount.csv"
$SitesData = @()
#Connect to PnP Online
Connect-PnPOnline -URL $SiteURL -Interactive
#Get All Site Collections
$SiteCollections = Get-PnPTenantSite
#Loop through each site
ForEach($SiteColl in $SiteCollections)
{
#Get the Site
$Site = Get-PnPTenantSite -Identity $SiteColl
#Collect Data
$SitesData += New-Object PSObject -property $([ordered]@{
SiteName = $Site.Title
SiteURL = $Site.Url
Subsites = $Site.WebsCount-1
})
}
$SitesData
$SitesData | Export-CSV $CSVFile -NoTypeInformation
Nếu bạn muốn biết thêm chi tiết về các site và site con, hãy tham khảo: SharePoint Online: PowerShell để lấy tất cả các tuyển tập site và site con