Quantcast
Viewing all articles
Browse latest Browse all 10

Code Snippet – Uninstall and Install SharePoint Solution Package

3 votes, 5.00 avg. rating (97% score)

Introduction

Quick snippet of power shell script how to uninstall and install a wsp in SharePoint 2013

Uninstall wsp / Install wsp


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
$SolutionPackageName = "MyWebStyles.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


Viewing all articles
Browse latest Browse all 10

Trending Articles