A missing feature in content db refers to orphan references to uninstalled features.
Painful among these would be the features that are scoped at web.
One possible cause of this could be the way the feature was uninstalled. if the feature was uninstalled with powershell script logic
$subwebs = get-spweb -site xxxxx
foreach($web in $subwebs)
disable-spfeature -identify yyyy -url $web.url
it will appear fine but fail in some farms where the number of sub webs in high use
$subwebs = get-spweb -site xxxxx -Limit all
is the right way
but this is postmortem, what do we do about features that are missing at web levle
There are quite a few things you may have to do
1. Identify the missing feature
you can do that by taking the feature id from test-spcontentdatabase command and searching it in dev environment or your source code repository
2. Re-install the missing feature
bring it back to the environment - reinstall it
3. Deactivate properly at all web levels
write powershell script to loop through and disable the feature at all levels
here is a sample code:
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
$featureid = $args[0]
$featuretocheck = Get-SPFeature -Identity $featureid
Write-Host "Checking for feature" $featuretocheck.DisplayName
$webapps = Get-SPWebApplication
foreach ($webapp in $webapps)
{
Write-Host "looping through webapp" $webapp.url
$sites = Get-SPSite -WebApplication $webapp -Limit ALL
foreach ($site in $sites)
{
Write-Host "looping through site" $site.url
$subwebs = Get-SPWeb -Limit ALL -Site $site
foreach ($subweb in $subwebs)
{
Write-Host "verifying web" $subweb.title
$feature = Get-SPFeature -Identity $featureid -Web $subweb -ErrorAction SilentlyContinue
if ($feature)
{
Write-Host "Activated -" $subweb.title -ForegroundColor Red
#Disable-SPFeature -Identity $featureid -Url $web.url }
else
{
Write-Host "Not Activated -" $subweb.title -ForegroundColor Green
}
}
}
}
Painful among these would be the features that are scoped at web.
One possible cause of this could be the way the feature was uninstalled. if the feature was uninstalled with powershell script logic
$subwebs = get-spweb -site xxxxx
foreach($web in $subwebs)
disable-spfeature -identify yyyy -url $web.url
it will appear fine but fail in some farms where the number of sub webs in high use
$subwebs = get-spweb -site xxxxx -Limit all
is the right way
but this is postmortem, what do we do about features that are missing at web levle
There are quite a few things you may have to do
1. Identify the missing feature
you can do that by taking the feature id from test-spcontentdatabase command and searching it in dev environment or your source code repository
2. Re-install the missing feature
bring it back to the environment - reinstall it
3. Deactivate properly at all web levels
write powershell script to loop through and disable the feature at all levels
here is a sample code:
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
$featureid = $args[0]
$featuretocheck = Get-SPFeature -Identity $featureid
Write-Host "Checking for feature" $featuretocheck.DisplayName
$webapps = Get-SPWebApplication
foreach ($webapp in $webapps)
{
Write-Host "looping through webapp" $webapp.url
$sites = Get-SPSite -WebApplication $webapp -Limit ALL
foreach ($site in $sites)
{
Write-Host "looping through site" $site.url
$subwebs = Get-SPWeb -Limit ALL -Site $site
foreach ($subweb in $subwebs)
{
Write-Host "verifying web" $subweb.title
$feature = Get-SPFeature -Identity $featureid -Web $subweb -ErrorAction SilentlyContinue
if ($feature)
{
Write-Host "Activated -" $subweb.title -ForegroundColor Red
#Disable-SPFeature -Identity $featureid -Url $web.url }
else
{
Write-Host "Not Activated -" $subweb.title -ForegroundColor Green
}
}
}
}
1 comment:
thanks
Post a Comment