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