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

[玩转系统] 查找 SharePoint 网站使用的所有网站模板

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

查找 SharePoint 网站使用的所有网站模板


要求:在继续迁移之前查找 SharePoint 2010 环境中使用的所有网站模板并生成报告,因为某些模板在 SharePoint 2013 中已停用。

解决方案:让我们使用 PowerShell 获取所有网站的网站模板使用情况报告。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables
$WebAppURL="https://sp10.crescent.com" 

#Get All Webs
$WebsCollection = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Get-SPWeb -Limit All

#Retrieve Site template data from each web
foreach ($web in $WebsCollection)
{
     $SiteName = $web.Title
     $SiteURL = $web.Url  
     $SiteTemplate = $web.WebTemplate  
     $TemplateID = $web.WebTemplateID  
     Write-Host " $($SiteName), $($SiteURL), $($SiteTemplate) ,$($TemplateID)"  
}

用于获取所有站点的 Web 模板并导出为 CSV 报告的 PowerShell 脚本:

让我们稍微调整一下以查找所有网站模板并将它们导出到 CSV 文件。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Variables
$WebAppURL="https://portal.crescent.com"
$ReportFile="C:\Reports\WebTemplates.csv"
 
#Get All Webs
$WebsCollection = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Get-SPWeb -Limit All

#Array to Hold Result - PSObjects
$ResultCollection = @()
 
#Retrieve Site template data from each web
foreach ($web in $WebsCollection)
{  
        $Result = New-Object PSObject
        $Result | Add-Member NoteProperty SiteName($web.Title)
        $Result | Add-Member NoteProperty SiteURL($web.URL)
        $Result | Add-Member NoteProperty SiteTemplate($web.WebTemplate)
        $Result | Add-Member NoteProperty WebTemplateID($web.WebTemplateID)
        
        #Add the object with property to an Array
        $ResultCollection += $Result
}

Write-host "Web Templates Report Generated Successfully!" -f Green

#Export the result Array to CSV file
$ResultCollection | Export-CSV $ReportFile -NoTypeInformation

要查找特定网站正在使用的网站模板,请参阅如何在 SharePoint 中查找网站模板?

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

取消回复欢迎 发表评论:

关灯