Search This Blog

Tuesday, March 24, 2015

Uninstall and Install SharePoint Solution - SharePoint 2010/2013

Introduction

how to Uninstall and install a .wsp in SharePoint 2010/2013

Uninstall wsp / Install wsp

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
$SolutionPackageName = "XXXXX.wsp"
$solution = Get-SPSolution | where-object {$_.Name -eq $SolutionPackageName}
# check to see if solution package has been installed
if ($solution -ne $null) {
  # check to see if solution package is currently deployed
  if($solution.Deployed -eq $true){
    Uninstall-SPSolution -Identity $SolutionPackageName -Local -Confirm:$false
    Remove-SPSolution -Identity $SolutionPackageName -Confirm:$false
  }
}
Add-SPSolution -LiteralPath $SolutionPackagePath
Install-SPSolution -Identity $SolutionPackageName -Local -GACDeployment
Add a call to Get-SPSolution and conditional logic to determine whether the solution package is currently installed and deployed before attempting to retract or remove it. Once solution is find, then call to Uninstall-SPSolution and Remove-SPSolution will remove solution package.Then use Add-SPSolution and Install-SPSolution to install the solution.

No comments:

Post a Comment