My last addition to the community is a script that can help you with the patching of SharePoint environments. The script was from the beginning made for Cumulative Updates but can be used in other scenarios as well. As in all CU installations it’s done in two steps; install Binaries and then run the SharePoint Configuration Wizard/PSConfig. What I wanted the script to do was they key things.
- Log the amount of time it takes to install the updates to estimate downtime in produciton environment
- Be able to reuse it without having to change any code
- Be able to choose if I wanted to detach all content databases before the binaries and then attach it after psconfig and then have that automated.
The first two things are actually not that tricky but the last point needed some more efforts.
- This is how you work with the script:
Download it from [Download not found] of from the download section, and put it on the SharePoint server/servers that are about to be upgraded. - Create a folder on the same level as the SP-Upgrade.ps1 file and name it Media.
- Download and extract the CU or the patches that should be installed and put it in the Media folder.
- Rename the .exe files in the Media folder so that they have a digit in the beginning representing in what order they should be installed.
For instance, if you want to upgrade your MOSS environment you have both the WSS and MOSS CU name the WSS CU 01[WSSFilename].exe and 02[MossFileName].exe - Open up a PowerShell command window with enough priviliges to run the setup.
- Depending on your environment and what approach you want to use, run SP-Upgrade with any of the following switches.
| Switches | |
| -Binaries | Installs the binaries located in the Media folder |
| -PSConfig | Runs the SharePoint Product and Configuration Wizard using: psconfig -cmd upgrade -inplace b2b -wait -force (complete command-line reference found here: http://technet.microsoft.com/en-us/library/cc263093.aspx) |
| -DetachContentDBs | Used together with -Binaries. Detaches content databases before installing the media and stores them in a xml file named ContentDatabases.xml located in the same folder as your SP-Upgrade.ps1 file |
| -AttachContentDBs | Used together with -PSConfig. Attach content databases after PSConfig. Note that if you have several SharePoint Server this should be used on the last server when -PSConfig is run on all other servers. |
| -OnlyAttach | Will only attach databases using ContentDatabases.xml. Used if you have run PSConfig on all servers and then just want to attach it. |
| -OnlyExport | Will only export databases to ContentDatabases.xml. |
| -help | Displays the help topic |
When the script is run it will create a Log folder and put all logs in that folder. Except for the log files generated by the installation I create a log file named Upgradelog.log and will contain the steps taken by the script together with time stamps. The time stamps are also printed to the screen and can display installation times, detach and attach times of content db’s.
When detaching the content databases the following information is stored in the ContentDatabases.xml file:
Web Application URL
Content Database Name
Content Database Max Site Count
Content Database Site Warning Level
Content Database Read Only
Content Database Status
Content Database Server Name
Detached Time
Reattached Time (Used when attached)
Syntax examples
SP-Upgrade -help
Displays the help topic for the script
SP-Upgrade -Binaries
Installs the wss and MOSS Binaries on the local machine
SP-Upgrade -Binaries -DetacheContentDBs
Detaches all content databases and installs the wss and MOSS Binaries on the local machine
SP-Upgrade -PSConfig
Runs the SharePoint Product and Configuration Wizard
SP-Upgrade -PSConfig -AttachContentDBs
Runs the SharePoint Product and Configuration Wizard and attaches all content databases
SP-Upgrade -OnlyAttach
Attaches all Content databases found in ContentDatabases.xml
Feedback and ideas for improvement is more then welcome!







[...] After some feedback I have updated the SP-Upgrade script created 2 weeks ago. First there was a bug in the script related to the export of Web Application names and then I added switch that makes i possible to only export the content database information to an XML File. This is how the help looks now and you find more information about the script here: http://mysharepointofview.com/2010/03/automate-sharepoint-patching-with-powershell/ [...]
Hi Mattias,
This is a great script that we are suing for our MOSS servers. Do you have a script for sharepoint 2010 patching as well ? Thanks in advance
Ignore my comment , it works fine on sp2010 after modifying the script