I created and enhanced some PowerShell script code snippets for the purpose of fully automating any given SharePoint .WSP artifact deployment
Usual steps for a clean SharePoint deployment as follows:
DisableSPFeature(Disable-SPFeature cmdlet)
Disables a SharePoint Feature at the given scope. If the scope of the Feature is the farm, the URL is not needed. Otherwise, provide the URL at which this Feature is to be deactivated.
Usage: DisableSPFeature($CRMWebPartsFeatureId, $False)
UninstallSPFeature(Uninstall-SPFeature cmdlet)
Removes the specified feature definition from the collection of feature definitions in the farm.
Usage: UninstallSPFeature($CRMWebPartsFeatureId)
UninstallSPSolution($CRMWebPartsSolutionName, $False)
Retracts a deployed SharePoint solution.
Usage: UninstallSPSolution($CRMWebPartsSolutionName, $False)
RemoveSPSolution(Remove-SPSolution cmdlet)
Removes a SharePoint solution from a farm.
Usage: RemoveSPSolution($CRMWebPartsSolutionName)
AddSPSolution(Add-SPSolution cmdlet)
Adds a SharePoint solution package to the farm.
Usage: AddSPSolution($CRMWebPartsSolutionPath)
InstallSPSolution(Install-SPSolution cmdlet)
Deploys an installed SharePoint solution in the farm.
Usage: InstallSPSolution($CRMWebPartsSolutionName, $False)
EnableSPFeature(Enable-SPFeature cmdlet)
Enables an installed SharePoint Feature at the given scope.
Usage: EnableSPFeature($CRMWebPartsFeatureId, $False)
WaitForJobTimerToFinish (The Get-SPTimerJob & Start-Sleep cmdlet)
Reads a specified timer job, timer jobs of a specified type, or timer jobs defined for a specified scope. If no parameters are specified, this returns all timer job definitions for the farm. We will validate the state of the job in a while loop until null (finished) returned. Otherwise suspends the activity in a script or session for the specified period of time in our case 2 seconds.
Usage: WaitForJobToFinish
Please find the fully deployment script. Modify as need to fit your deployment.