Easily Deploy and Retract SharePoint solutions using PowerShell
Tools are extremely important. The invention of pontoons enhanced mobility in the battlefield and expedited the speed in which strategic aims had been met. Similarly, using SharePoint building and deployment tools, will enhance our ability to deliver, test
and redeliver. This frees developers, QA testers and end users to do more with their precious time.
We constantly deploy SharePoint solutions in farms. We eventually deploy the very same solutions and forms in Development, then QA, then UAT and finally in Production. Some companies may have a plethora of other farms as well. We also have to activate these
solutions. Doing all this manually, time and again is at least tiring, but it is also boring and error prone. It is nice to be able to do it automatically and repeat it accurately – I wrote the
script for this reason. But this isn’t all. How many times did you deploy a solution only to find that it is fraught with errors and – terror of terrors – creates problems that disrupt the work of the whole system?
Retracting such a solution – especially if an older version was deployed before and needs to be reinstated – is cumbersome and then some, but not any longer.
keeps track of changes and allows you to retract and reinstate with ease. This is especially important if you deploy multiple solutions at once – a feat that should be avoided, but is demanded of us by time-pressed and myopic PMs (an
error is much easier to pinpoint if we make just one change at a time). PSDeployRetract
easily deploys multiple solutions and easily retracts-reinstates all that it had deployed, allowing us then to deploy the solutions again, hopefully one by one.
The latest version of PSDeployRetract
also deploys InfoPath forms.
The Developer/Admin simply collects all the required solutions (wsp) and forms (xsn) files into a file folder, fills a few slots in an xml file that directs the script, launches the PowerShell Script, and watches how the work is done on his screen. If S/He
so wishes (no more PC language from now on), HE may view or print the associated report file.
The folder containing the WSPs and XSNs may contain more files than the ones you deploy. I actually put all of my solutions and form there and deploy them as needed. Only the files listed in the xml will be deployed.
Now, should this deployment have created a problem, he identifies the newly created backup folder and runs
in retract mode (Use the Restore
operation) using this backup folder. Important caveat: for safe operations you may only retract the latest!
Don’t retract far into the past!!!
You can perform only one operation. All the operations are case insensitive.
The operations are:
Find the features inside the WSPs and activate them in every site
: also create an XML file with an entry for each enabled feature.
: This will be used at restore time to disable them
Will span the list of WSPs and unistall them.
It'll first disable the features and create a backup of what it uninstalls
Will span the list of WSPs and install them
It will first unistall and old solution if one exists by diabling its features and unistalling.
Deploy will also enable and deploy forms
It'll also create a backup structure
Like deploy, but w/o enaabling features and w/o deploying forms
Will span all the XSNs and deploy the forms
Restoring is done as follows:
1. disable all the features in reverse order
2. RE-Deploy all the WSP from the backup
3. Retract all the "extra" WSPs
4. Enable all the features in straight order –
Note: Because some solutions might simply be extracted, you might get errors while trying to enable non-existing features. I could hide these errors, but I prefer to see them.
SPDeployRetract comes with the following files:
1. SPDeployRetract.docx – this document
2. SPDeployRetract.ps1 – the script The script is well commentted. It actually explains what it does.
3. SPDepolyConfigRestoreSample.xml – a restore example. It is well commentted. It actually explains what it does.
4. WSPDepolyConfigSample.xml – a Deploy example. It is well commentted. It actually explains what it does.
All the files are self documented. You do not have to go to this document to see how to prepare the xml files. Just use the files as they are and change the particulars to match your case. The instructions are built right in. They are all downloadable in this
The command line:
here are two examples of commands. You may also use the . style command.