Get all subsites of 2 levels using Powershell
-
23-01-2021 - |
سؤال
I have a site collection "IM". In this site collection I have many subsites and in every subsite I have other subsites.
How can I get all subsites of the site collection using Powrshell?
I started to get first level of subsites but not the second one:
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null) { Add-PSSnapin Microsoft.SharePoint.Powershell }
$IM = Get-SPWeb "http://manco-intranet/sites/investmentmanager/"
foreach($Site in $IM)
{
foreach($SubIM in $Site.Webs)
{
Write-Host $SubIM.title
}
}
المحلول
Try with this
Add-pssnapin "Microsoft.Sharepoint.Powershell"
Get-SPSite "http://SiteCollectionURL" | Get-SPWeb -Limit All | Select Title, URL |
Export-CSV C:\SharePoint_Sites_Report.csv -NoTypeInformation
Change SiteCollectionURL and path to csv (C:\SharePoint_Sites_Report.csv)
لا تنتمي إلى sharepoint.stackexchange