Using a VBScript to control Virtual Server on a remote computer

I was surprised to find out the other day that while I have posted many sample VBScripts – I have never discussed how to configure one of these scripts to operate on a remote server running Virtual Server.  This is really quite simple to do.  Each script starts by creating a COM object for Virtual Server – usually with a line like this:

set vs = wscript.CreateObject(“VirtualServer.Application”)

To operate on a remote server you just need to change this line to:

set vs = CreateObject(“VirtualServer.Application”, “serverName”)

And you can then continue to script against the remote Virtual Server instance just like it was a local instance.  Note – however – that in order for this to work you will need to:

  1. Either be an administrator on the remote computer – or do some funky DCOM configuration (that frankly makes my head hurt – search for information on Dcomcnfg.exe if you really want to know more)

  2. Ensure that your firewall is configured correctly.  If you are using the Windows Firewall this can be done by opening TCP port 135 on the computer that is issuing the command (this is used for DCOM – and can be done by running ‘netsh firewall add portopening protocol=tcp port=135 name=DCOM_TCP135’) and enabling remote administration on your target computer (this can be done by running ‘netsh firewall set service RemoteAdmin enable’)