Put together a small script that to help automate deployment of a solution. The script handles the following:
- Install and Deploy a farm level solution
- Activate a web application scoped feature
- Activate a site collection scoped feature
The tricky part with scripting this occurs when the solution is deployed [Install-SPSolution cmdlet]. The script needs to wait for the deployment to finish before activating the features. Without waiting, the script will immediately continue, and try to activate the features that have not been deployed yet. That means evil red text will appear complaining about features not existing in the farm.
Here’s a copy of the script. There are some things hard coded in this sample. The name of the solution package on the Install-SPSolution line, and the Feature ID’s on the Enable-SPFeature lines.