Export/Import SharePoint 2010 solutions using PowerShell (Part 3/3)

This last part will contain a script that will deploy the solutions to all available web applications. So you should only use this script if the solutions that are not deployed, have to be deployed on all SharePoint 2010 Web Applications.
Alternitavely, you can also change the script to only deploy the solution to 1 or more Web Applications.

Just to make sure, I Added a “Warning box”, which will display the information described above for people who had no time to read the piece of information.

#This script will deploy all added solutions to all web applications
Add-PSSnapin Microsoft.SharePoint.PowerShell

function deploySolutions
    $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes"
    $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No"
    $choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No)
    $caption = ""
    $message = "Choosing YES will deploy ALL solutions available to ALL web applications, are you sure?"
    $result = $Host.UI.PromptForChoice($caption,$message,$choices,0)
    if($result -eq 0)
        Get-SPSolution | ForEach-Object {If ($_.ContainsWebApplicationResource -eq $False) {Install-SPSolution -Identity $_ -GACDeployment} else {Install-SPSolution -Identity $_ -AllWebApplications -GACDeployment}}
    elseif($result -eq 1)
        Write-Host "you chose not to deploy the solution, press any key to exit" -fore red
        $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")


The output of the above script will look similar to this:

Improvements for all scripts posted are very welcome!.

Happy scripting!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s