Here's an quick and very useful script often requested by admin guys that I'd like to share and hopefully it will be useful to someone as well: list all the sites for a SharePoint Url and its owners.
Made in PowerShell
function List-Sites([string]$url)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") > $null
$rootSite = new-object Microsoft.SharePoint.SPSite($url)
$webApp = $rootSite.WebApplication
if($webApp.Sites.Count -gt 0)
{
write-output "site url`tlast date content modified`tsite owner`tsite name`tsite url`tsite template`tsite description"
foreach ($site in $webApp.Sites)
{
$rootweb = $site.RootWeb
$allwebtemplates=$rootweb.GetAvailableWebTemplates(1033)
foreach($template in $allwebtemplates)
{
if ($template.ID -eq $rootweb.WebTemplateId)
{
$templatename=$template.Title
}
}
$lastUpdatedDate = Get-Date "1/1/2000 1:00 AM"
foreach($web1 in $site.AllWebs)
{
foreach($list in $web1)
{
if ($lastUpdatedDate -lt $list.LastItemModifiedDate)
{
$lastUpdatedDate=$list.LastItemModifiedDate
}
}
}
$SiteAdmin = new-object Microsoft.SharePoint.Administration.SPSiteAdministration($rootweb.URL)
write-output "$($site.Url)`t$($lastUpdatedDate)`t$($site.Owner.LoginName)`t$($rootWeb.PortalName) $($rootWeb.Title)`t$($site.PortalUrl)`t$($rootWeb.WebTemplate) ( $templatename )`t$($rootWeb.Description)"
$SiteAdmin.Dispose()
$rootweb.Dispose()
}
}
$rootSite.Dispose()
}
There is also a reference for the object SPSiteAdministration just in case you want to output more information.
Execute this script in the Powershell command line in your server and the output will be something like this:
Solution 2:
Not really a good solution if you have several sites; but if you just want to quickly find out the templates of a specific site alternatively you can go to your root web site and add this to your query string: /_vti_bin/owssvr.dll?Cmd=GetProjSchema
this will display the ONET.XML for that site, and if you scroll down until the Configuration node you can get the template being used currently
The admin guys are happy, developers are happy... win-win :)
See you later,
By Edge Pereira
Like your workaround - thanks!
ReplyDelete