Wednesday, May 18, 2011

Missing features\site templates: How to identify?

Do you want to know what features are missing on your environment and where they are in use?

Here is a tool to find out: WssAnalyzeFeatures. It will give you a log with missing features

Another option is to use the following  PowerShell script (you can actually undo the comment to delete the missing features):
$siteurl = 'http://localhost' 

$site=[Microsoft.SharePoint.SPSite]($siteUrl)
    foreach ($feature in $site.features) {    
          if ($feature.definition -eq $null) 
{        
        write-host "Missing site feature:"
        write-host $feature.DefinitionId
        write-host $feature.parent
#      $site.features.remove($featureid)
     }   }   
    
$webs = $site.AllWebs
   foreach ($web in $webs) {   
foreach ($feature in $web.features) {     
        if ($feature.definition -eq $null) 
{        
        write-host "Missing web feature:" 
        write-host $web
        write-host $web.url
        write-host $feature.DefinitionId
        write-host $feature.parent
#      $site.features.remove($featureid)     
}   }   
    }
 And the last option for more visual people the freeware tool with the name FaultyFeatureTool

Missing the site templates?
Here is the PowerShell script to identify the site that uses the missing site template:

$webAppUrl = Read-Host "Please enter url for web application to find missing templates"
Write-Host " "
Write-Host "Here the site with missing templates on the web application $webAppUrl"
Write-Host " "
$WA = [Microsoft.SharePoint.Administration.Spwebapplication]::Lookup($webAppUrl)
$wa.Sites|foreach {$_.AllWebs| foreach {if($_.WebTemplate -eq '') {$_.Url, $_.WebTemplateId}}}