Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have added a new web part to a feature of existing web parts in a wsp solution. If I manually go to a site collection and deactivate and reactivate the feature via site collection features, the new web part is available in the gallery and can be added onto a page.

I am upgrading this solution across many site collections using powershell. My powershell script loops through the site collections. If it finds the updated feature it deactivates the feature using Disable-SPFeature ...and then I run Enable-SPFeature bla bla to activate it again.

I have stepped through and run the powershell manually and can see the feature activated and deactivated and reactivated again if I refresh the browser and then run each command but the new web part does not get added to the gallery this way.

Can anyone shed any light on why the new .webpart file doesn't get added via the powershell method?

Here is a sample of the powershell where I do the work:

First after upgrading the solution I run this to force the xml to the file system.

Install-SPFeature -Path "Intranet.WebParts_Site-WebParts" -Force

foreach ($site in $webApp.Sites)
{       
        if ($site.Features[$myportalWebPartsFeatureId] -ne $null)
        {
            Write-host "Disabling Web Parts feature" -ForegroundColor Cyan              
            Disable-SPFeature "Intranet.WebParts_Site-WebParts" -Url $site.Url -confirm:$false
            Write-host "Enabling Web Parts feature" -ForegroundColor Cyan               
            Enable-SPFeature "Intranet.WebParts_Site-WebParts" -Url $site.Url -confirm:$false
        }
share|improve this question
    
What is the full version number (or Cumulative Update) of your installation? –  James Love Nov 27 '12 at 19:19
    
Can you share feature activation code? Does it work manually using GUI feature activation? –  Falak Mahmood Nov 27 '12 at 22:43
    
No feature activation code used. Works perfectly using GUI activation. Version: SharePoint Server 14.0.6029.1000 + hotfix 14.0.6106.5002 for portal –  Grooverinthesouth Nov 28 '12 at 9:46
add comment

1 Answer

I had faced the same problem. I used the Install-SPFeature command after Disable-SPFeature and it worked for me.

Write-host "Disabling Web Parts feature" -ForegroundColor Cyan              
Disable-SPFeature "Intranet.WebParts_Site-WebParts" -Url $site.Url -confirm:$false

Install-SPFeature "Intranet.WebParts_Site-WebParts" -Force


Write-host "Enabling Web Parts feature" -ForegroundColor Cyan               
Enable-SPFeature "Intranet.WebParts_Site-WebParts" -Url $site.Url -confirm:$false
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.