Code Snippet – Uninstall and Install SharePoint Solution Package
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
January 19, 2014
В·
Adi В·
No Comments
Tags: code snippet, Packaging and deployment, Powershell, SharePoint 2010, SharePoint 2013 В· Posted in: Packaging and Deployment, Powershell, Sharepoint 2010, SharePoint 2013
Leave a Reply