Sunday, December 12, 2010

Get sandboxed solution on the farm

How to get all sandboxed (user solution) installed on the SharePoint farm.

  1. $gc = Start-SPAssignment
  2. $gc | Get-SPSite | Get-SPUserSolution
  3. Stop-SPAssignment $gc


The output:



Name                                SolutionId                                                      Status

----                                     ----------                                                         ------


Contacts.wsp                   3089ef04-527e-4b35-a0a2-af5f4df8a71b     Activated


Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated


Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated


Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated


Sandboxed1.2.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated


Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Activated



It is really simple to get a full list of sandboxed solutions, but the output is not useful, because we can see which site collection the sandboxed solution is store in.



This small PowerShell script will display the site collection url



  1. function Get-UserSolution
  2. {
  3. param(
  4. [Parameter(
  5. Position=0,
  6. Mandatory=$true,
  7. ValueFromPipeline=$true,
  8. ValueFromPipelineByPropertyName=$true)
  9. ]
  10. $SiteCollection
  11. )
  12. process
  13. {
  14. Write-host "Site Collection:" $SiteCollection.Url
  15. $gc = Start-SPAssignment
  16. $SiteCollection | Get-SPUserSolution -AssignmentCollection $gc
  17. Stop-SPAssignment $gc
  18. }
  19. }
  20. Get-SPSite | Get-UserSolution


The output:



Site Collection: http://win-ugka6ujlm21



Name                               SolutionId                                                       Status               
----                                    ----------                                                          ------               
Contacts.wsp                   3089ef04-527e-4b35-a0a2-af5f4df8a71b     Activated            
Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated          
Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated            
Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated            
Sandboxed1.2.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated          
Site Collection: http://win-ugka6ujlm21/my


Site Collection: http://win-ugka6ujlm21/sites/sandbox


Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Activated  



The code:

1 comment: