4

I need to retrieve the details of all deployed SharePoint solutions, as are displayed in the Central Administration > Operations > Solution Management (AKA the Solution Store), using a PowerShell script (v2.0). Can anyone offer any guidance on how to retrieve this information from the SharePoint solution store via the SharePoint API?

Thanks, MagicAndi.

Tangiest
  • 43,737
  • 24
  • 82
  • 113

4 Answers4

8

This is actually pretty easy to do. You conect to the SP Farm and just request get_Solutions.

Here is an example:

# Connect to the Farm
$SPfarm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()

# What Solution are we looking for?
$solution = "sharepointlearningkit.wsp";

# Get the solutions
$currentSolution = $SPfarm.get_Solutions() | Where-Object { $_.DisplayName -eq $solution; }
$currentSolution;
Mitchell Skurnik
  • 1,419
  • 4
  • 25
  • 37
3

Based on Mitchell's answer, I have used:

    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

    function Get-LocalSPFarm()
    {
       return [Microsoft.SharePoint.Administration.SPFarm]::Local
    }

    function List-Solutions()
    {
        $farm = Get-LocalSPFarm        
        foreach ($solution in $farm.Solutions) 
        {
            Write-Host($solution.DisplayName)
            # Get-Member -InputObject $solution -MemberType property
        }
    }

All credit to Mitchell!

Community
  • 1
  • 1
Tangiest
  • 43,737
  • 24
  • 82
  • 113
2

You can call stsadm.exe -o enumsolutions from your powershell script. It returns XML data which you can easily convert to [xml] data type and see whatever you need from that.
(stsadm lives in c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin)

The output consists of statements similar to this

<Solution Name="yoursolution.wsp">
  <Id>ab693dcd-6483-45ad-abba-9c996c67b6e0</Id>
  <File>yoursolution.wsp</File>
  <Deployed>TRUE</Deployed>
  <WebApplicationSpecific>TRUE</WebApplicationSpecific>
  <ContainsGlobalAssembly>TRUE</ContainsGlobalAssembly>
  <ContainsCodeAccessSecurityPolicy>FALSE</ContainsCodeAccessSecurityPolicy>
  <Deployment WebApplication="http://devserver/" />
  <LastOperationResult>DeploymentSucceeded</LastOperationResult>
  <LastOperationTime>10/26/2009 9:06 AM</LastOperationTime>
</Solution>
naivists
  • 32,681
  • 5
  • 61
  • 85
1

Here are three powershell cmdlets I use to pull back the solution information. Mine are simple compared to the ones above but I thought I would submit them anyway :)

In SP2010 Management Shell

To list all the solutions. Returns solution name, id and deployed status

Get-spsolutions

To list all the properties of a particular solution

get-spsolution -identity | select *

List all solutions, properties and output to a file to read :)

get-spsolution | select * | out-file c:\solutions.txt

Community
  • 1
  • 1
Jen
  • 11
  • 1