Thursday, March 24, 2011

Changing Drive Letter with MSDeploy

I've been doing a lot of migrations from IIS6 to IIS7 recently. This is a handy way of changing the drive letter when using Microsoft Web Deploy to import a site into IIS, say from drive C:\ to D:\

A Full Command Changing the Source Directory of the Archive "msdeploy-site" From "C:\" to "D:\":

Note: That there are no carriage returns, it's one long string.

C:\Program Files\IIS\Microsoft Web Deploy>msdeploy -verb:sync -source:archivedir=D:\msdeploy-site -dest:metakey=lm/w3svc/1863507787 -replace:objectName="metaProperty",scopeAttributeName="name",scopeAttributeValue="Path",targetAttributeName="value",match="c:",replace="d:"

The "replace" here looks for "c:" and changes it to "d:", which will now put the archive under d: when it was originally on c: on the source server.

Excerpt of the relevant part of the command:
-replace:objectName="metaProperty",scopeAttributeName="name",scopeAttributeValue="Path",targetAttributeName="value",match="c:",replace="d:"

Just change the drive letters of "match" with the original drive from the source server and "replace" with the destination drive on the new server.

Now, let's say you wanted to test this command before you ran it. Well then you do this:

C:\Program Files\IIS\Microsoft Web Deploy>msdeploy -verb:sync -source:archivedir=D:\msdeploy-site -dest:metakey=lm/w3svc/1863507787 -replace:objectName="metaProperty",scopeAttributeName="name",scopeAttributeValue="Path",targetAttributeName="value",match="c:",replace="d:" -verbose -whatif

The "-verbose -whatif" will run the command as a test in verbose mode in the command prompt and let you know if there are any issues it runs into and allow you to confirm that the drive letter destination is correct. You can also output this to a file using " > output.txt"

Let me know how this works out for you.

3 comments:

Anonymous said...

Thanks, this was very handy!

Sean Sliwinski said...

Made my day on this.... thanks.

Catalin Soare said...

Awesome!
Thank you for this post! I find msdeploy's help and online documentation really even worse than some Unix manspages.