Option Explicit
dim vs, newVNetName, counter, hostNics, hostNic, hostNicNumber, newVNet
'Connect to Virtual Server
Set vs = CreateObject("VirtualServer.Application")
'Get name for new virtual network
wscript.echo "Please enter the name of the new virtual network to create:"
newVNetName = wscript.StdIn.ReadLine
wscript.echo
'Display list of network adapters on the host
wscript.echo "Available physical network adapters:"
wscript.echo "===================================="
hostNics = vs.HostInfo.NetworkAdapters
counter = 0
for each hostNic in hostNics
wscript.echo cstr(counter) + ": " + hostNic
counter = counter + 1
next
wscript.echo cstr(counter) + ": No host connection"
wscript.echo
'Get a physical network adapter
wscript.echo "Please enter the number for the physical network adapter to use:"
hostNicNumber = wscript.StdIn.ReadLine
wscript.echo
'Check for valid input
if (cint(hostNicNumber) < 0) or (cint(hostNicNumber) > counter) then
wscript.echo "Invalid number specified"
wscript.quit
end if
'Create new virtual network in default location
set newVNet = vs.CreateVirtualNetwork(newVNetName, vs.DefaultVNConfigurationPath)
'Connect new virtual network if appropriate
if cint(hostNicNumber) < counter then
newVNet.HostAdapter = hostNics(hostNicNumber)
end if
wscript.echo "A new virtual network has been created"