Cloning SharePoint 2010 development images (for Hyper-V)

Before we begin, I´d like to point out the obvious: You want to clone a VM that is as clean as possible (without needing to install all the software on each clone of course). So clone your VM before creating any sites, since all references will be broken when you change the name.

This has been tested with a VM containing the following software:

  • Windows Server 2008 R2
  • SQL Server 2008 Express
  • SharePoint 2010 Enterprise
  • Visual Studio 2010 Premium
  • Office Professional Plus 2010

First, the best way to clone the VM for use in your Hyper-V setting. Contrary to what you might expect, this is not by using the export/import functions of Hyper-V Manager. This is actually meant for backup/restore.

The best way I have found is to just stop the VM you want to clone, copy the VHD, create a new VM definition and attach it to the copied VHD.

Next, the VM must be renamed. These steps are based on the MOSS 2007 cloning steps outlined here: http://www.sharepointdevwiki.com/display/public/Cloning+a+SharePoint+Virtual+Machine

  1. Stop the SharePoint Search services(s). I stopped both the “SharePoint Foundation Search V4” and “SharePoint Server Search 14” services to be sure.
  2. Go to System Properties and rename the VM, but don’t restart yet.
  3. Open “SQL Server Management Studio” and connect to “(local)”.
  4. Run the following query:
    EXEC sp_dropserver '<old_name>'
    GO
    EXEC sp_addserver '<new_name>', 'local'
    
  5. Run the “renameserver” stsadm command:
    stsadm -o renameserver -oldservername <old server name> -newservername <new server name>
    
  6. Now restart the VM.
  7. Rebuild Central Administration:
    psconfig -cmd adminvs -provision -port 12345 -windowsauthprovider onlyusentlm
    
  8. Restart IIS.
  9. Open Central Administration and delete the applications that are based on the old machine name.

Aaaand, you’re good to go.

Posted in .NET | Tagged | 3 Comments

Don't use tabs in UserProfile ChoiceList values

When attempting to assign a UserProfile property, SharePoint does some character escaping. One of the things it does is convert tab-character to &#9;. The problem is that the allowed values for a ChoiceList do not have this escaped sequence. The result is that the assignment of the value fails with an exception, because it does not match any of the allowed ChoiceList values.

So: Don’t use tabs in ChoiceList values!

Posted in .NET | Tagged , , | Leave a comment