I am trying to deploy or update a WSP solution to SharePoint in a script using Update-SPSolution. The problem I have is that if this is the initial install I need to use Add-SPSolution and then Install-SPSolution to deploy it and then run Update-SPSolution. If the WSP has already been deployed I can just run Update-SPSolution. How do I check if the WSP has been Added and or Deployed to the Farm?
Get-SPSolution returns an array of SPSolutions added to the farm. You can compare a solution's name or GUID (SolutionID) to your solution and check the Deployed property to see if it's currently deployed.
Get-SPSolution -Identity "intranet.publishing.wsp" | select deployed, lastoperationresult
This will retrieve any solutions called "intranet.publishing.wsp" and if it exists display its Deployed and LastOperationResult values.
Every time that I have tried to use use the
Update-SPSolution command it never works the way I think it should so instead, I always use the deactivate-retract-delete-add-deploy-activate approach just as if it were a new solution.
Per TechNet : "The Update-SPSolution cmdlet upgrades a deployed SharePoint solution in the farm. Use this cmdlet only if a new solution contains the same set of files and features as the deployed solution. If files and features are different, the solution must be retracted and redeployed by using the Uninstall-SPSolution and Install-SPSolution cmdlets, respectively."
There are more details on MSDN as well
What's the scenario here? Are you adding a new WFE and want to know if the solution has been deployed to that new WFE, or are you upgrading an existing solution that's already deployed? Update-SPSolution will not "re-deploy" per say. It will update components of that solution that have changed, but unless you're handling changes to the solution with code using feature version, new items will not be deployed as part of an Update-SPSolution call.
For example, if you add a new module with new masterpages and package, then run Update-SPSolution, your new module won't be processed. Those initial deployment tasks don't fire as part of an update. You would need code to handle the difference in version between what's on the server and the version you're now deploying, and instruct that code that if the version is n.n.n.n to process that module since it wouldn't have been there. There's a great webcast by Jeremy Thake on that side of feature development.
If you're just looking for solution status, there's a couple good blog posts out there that have methods for grabbing the last operation status of a solution with PowerShell... those are probably a good starting point (this one for example).
One thing you may want to do is close your PowerShell window (PowerShell ISE or PS Management Shell) - apparently the WSP referenced by the Upgrade-SPSolution caches the WSP.
Here's a description of the issue - similar to my own.
Jeremy Thake's webcast video references this issue, if you managed to catch it. I hope this is resolved in SP 2013.