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
}