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
$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