Install WSP with Powershell

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

$SolutionPackageName = "MySolution.wsp"
$SolutionPackagePath = "C:\PowershellSetup\MySolution.wsp"

Write-Host "Checking Solution exist or not..." -foregroundcolor Yellow
$solution = Get-SPSolution | where-object {$_.Name -eq $SolutionPackageName}
if($solution -ne $null)
{
Write-Host "Solution Found..." -foregroundcolor Green
if($solution.Deployed -eq $true)
{
Write-Host "Uninstalling Solution..." -foregroundcolor red
Uninstall-SPSolution -Identity $SolutionPackageName -Local -Confirm:$false
Write-Host "Uninstallation Done..." -foregroundcolor Yellow
}
Write-Host "Removing Solution..." -foregroundcolor red
Remove-SPSolution -Identity $SolutionPackageName -Confirm:$false
Write-Host "Solution Removed..." -foregroundcolor Yellow
}

Write-Host "Adding Solution..." -foregroundcolor red
Add-SPSolution -LiteralPath $SolutionPackagePath
Write-Host "Solution Added..." -foregroundcolor Yellow

Write-Host "Installing Solution..." -foregroundcolor red
Install-SPSolution -Identity $SolutionPackageName -Local -GACDeployment -Force
Write-Host "Solution Installed..." -foregroundcolor Yellow
Write-Host "Deployment Complete." -foregroundcolor Green

Comments

Popular Posts

SharePoint Interview Questions and Answers

Download Infopath Form Templates

How to get current logged user information using JavaScript ?

Steps to set Form based authentication (FBA) for SharePoint 2010

SharePoint Interview Questions and Answers II

Get List Items - JavaScript

Cross Site List Rollup Web Part for SharePoint 2010

Hide Recently Modified Items

Change Language for current user with JSOM in SharePoint Online

SharePoint 2010 CSS Chart