Use below functions to check and fix the features during sharepoint 2007 to 2010 migration.

function getspmissingfeatures([string]$siteurl)
{
  $site = get-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
    }
  }

  $webs = $site | get-spweb -limit all
  foreach ($web in $webs) {
  foreach ($feature in $web.features) {
    if ($feature.definition -eq $null) {
       write-host “Missing web feature:”
       write-host $web.url
       write-host $feature.DefinitionId
       write-host $feature.parent 
    }
  }

  }

}

function removespmissingfeatures([string]$siteurl)
{
  $site = get-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($feature.DefinitionId)
       write-host “Missing site feature deleted:”
       write-host $feature.DefinitionId
       write-host $feature.parent
    }
  }

  $webs = $site | get-spweb -limit all
  foreach ($web in $webs) {
  foreach ($feature in $web.features) {
    if ($feature.definition -eq $null) {
       write-host “Missing web feature:”
       write-host $web.url
       write-host $feature.DefinitionId
       write-host $feature.parent
      $web.features.remove($feature.DefinitionId)
       write-host “Missing web feature deleted:”
       write-host $web.url
       write-host $feature.DefinitionId
       write-host $feature.parent
    }
  }

  }
}

Advertisements