none
Activate user solution in all subsites within a site collection RRS feed

  • Question

  • I am really struggling here, I have deployed a custom workflow solution adn deployed it to my root PWA site, now I need to go through each site and activate the feature under Site Settings > Site Actions > Manage Site features. Obviously I dont want to do this manually as I have over 50 sites, bring on powershell!

    For site collection features I can easily do this but how do I do it in this instance as the feature is activated locallly to each subsite?

    This is what I have so far but it appears I am using the wrong method of activating the user solution as I receive an error:

    $rootsite = "http://mysite.co.co.uk/PWA"
    $webs = $rootsite | Get-SPweb -limit all
    foreach ($site in $webs)
    	{
    	write-host "Web URL = " $site.URL -foregroundcolor "blue"
    	enable-SPFeature -Identity "CRRefGen.wsp" -url $web
    	}

    Should I be using something like, the below? I cant get either to work?

    Install-SPUserSolution -URL $web
    Thanks in advance

    Colin Cook.

    Wednesday, August 8, 2012 9:59 AM

Answers

All replies

  • Hi Colin,

    On the enable-SPfeature command you have specified $web but this variable doesn't exist in your script. Try the line below:

    enable-SPFeature -Identity "CRRefGen.wsp" -url $site
    

    Can you get the script to work for just one project site using the line above?

    Thanks

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com

    Wednesday, August 8, 2012 12:58 PM
    Moderator
  • Apologies it was a mixmatch of me tweaking the script around, I have also run the below but with no luck

    $rootsite = "http://testprojects.cofunds.co.uk/PWA"
    $webs = $rootsite | Get-SPweb -limit 2
    foreach ($site in $webs)
    	{
    	write-host "Web URL = " $site.URL -foregroundcolor "blue"
    	enable-SPFeature -Identity "CRRefGen.wsp" -url $site
    	write-host "Feature installed to " $site -foregroundcolor "green"
    	}

    This is the error I receive:

     "The Feature is not a Farm Level Feature and is not found in a Site level defined by the Url"


    Colin Cook.

    Wednesday, August 8, 2012 1:05 PM
  • Hi Colin,

    If you run the command below (update the Project site URL) do you see this feature:

    Get-SPFeature -Web http://testprojects.cofunds.co.uk/PWA/Projectsite1

    Thanks

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com

    Wednesday, August 8, 2012 1:46 PM
    Moderator
  • Hi Paul, I do see the feature but with a slighlty different name:

    CRRefGenListInstances


    Colin Cook.

    Wednesday, August 8, 2012 1:55 PM
  • Try your command with that name or even use the GUID. Test the command for one site first then put into a foreach loop.

    Thanks

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com

    Wednesday, August 8, 2012 1:58 PM
    Moderator
  • Thanks paul, the below works, I was also trying to use the name of the site previously so by adding in $url = $site.URL and using $Url for the parameter it worked, the final below script works, I just need to refine it now, thanks for your help.

    $rootsite = "http://testprojects.cofunds.co.uk/PWA"
    $webs = $rootsite | Get-SPweb -limit 2
    foreach ($site in $webs)
    	{
    	$url = $site.URL
    	write-host "Web URL = " $url -foregroundcolor "blue"
    	enable-SPFeature -Identity "31d8d82b-a3e2-4c91-bcbd-25dffd23d6ca" -url $url
    	}


    Colin Cook.

    Wednesday, August 8, 2012 2:15 PM
  • No problem, glad to have helped you resolve your issue.

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com

    Wednesday, August 8, 2012 2:20 PM
    Moderator