Creating an IIS website change deployment script

less than 1 minute read

Often, I need to deploy an website change to a production server. It can be a simple change like creating a virtual directory and rather rarely very big like setting up a new site. We export iis website setting, delete everything but the change, and import the change using vbscript.  The command is like this.

[sourcecode language='vb']
Set IIsComputer = GetObject("winmgmts://localhost/root/MicrosoftIISv2:IIsComputer='LM'")
IIsComputer.Import "", strFilePath, strSourceMetabasePath, strDestinationMetabasePath, intFlags

The xml file only contains the part that changed and has a basic skeleton tags

[sourcecode language='xml']

<iiswebdirectory location="/LM/W3SVC/00/ROOT/jsk" ...>