Okay, before anyone comments on the simplicity of this posting. It merely t allow me to get the script easily in the future. What’s the purpose of it? It basically retracts a solution and waits until its fully retracted, then deletes it, adds it in again and redeploys it. Not rocket science, but handy.
#Set up Web Application variable
#Only needed if solution contains Web Application scoped resources
$webApp = "http://sitetodeployto"
#Set up solution name variable
$solutionName = "solution.wsp"
#Set up solution file path variable
$filePath = "C:\Deploy51011\" + $solutionName
#Uninstall solution
#Add -WebApplication $webApp if solution contains Web Application scoped resources
Uninstall-SPSolution –Identity $solutionName –WebApplication $webApp -Confirm:$false
#set up a variable for the solution to allow access to properties
$solution = Get-SPSolution $solutionName
#Wait for solution to be uninstalled
do {Start-Sleep -s 1} while ($solution.Deployed -eq $true)
# add another couple of seconds
Start-Sleep -s 2
#Remove solution from the farm without prompting
Remove-SPSolution $solutionName -Confirm:$false
# add it back in and deploy it
Add-SPSolution –LiteralPath $filePath
Install-SPSolution –Identity $solutionName –WebApplication $webApp –GACDeployment
Hope this saves someone some time Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Clik here to view.
