読者です 読者をやめる 読者になる 読者になる

ネットワークのオフラインとオンライン

Virtual Machine "VM"をネットワークオフラインに。

Const VN_EXT = "外部ネットワーク"

Set objVS = CreateObject("VirtualServer.Application")

Set objVMExt = objVS.FindVirtualNetwork(VN_EXT)

Call DetachFromVirtualNetwork("VM")

Set objVMExtNICs = objVMExt.NetworkAdapters

For each objPropNICs in objVMExtNICs
  WScript.Echo objPropNICs.VirtualMachine
Next

Private Sub DetachFromVirtualNetwork(ByVal strVMName)
  Set objVM = objVS.findVirtualMachine(strVMName)

  Set colNICs = objVM.NetworkAdapters

  For each objPropNIC in colNICs
    objPropNIC.DetachFromVirtualNetwork
  Next

  Set objVM = Nothing
End Sub


ネットワークをVirtual Network"外部ネットワーク"に接続

Const VN_EXT = "外部ネットワーク"

Set objVS = CreateObject("VirtualServer.Application")

Set objVMExt = objVS.FindVirtualNetwork(VN_EXT)

Call AttachToVirtualNetwork("VM")

Set objVMExtNICs = objVMExt.NetworkAdapters

For each objPropNICs in objVMExtNICs
  WScript.Echo objPropNICs.VirtualMachine
Next

Private Sub AttachToVirtualNetwork(ByVal strVMName)
  Set objVM = objVS.findVirtualMachine(strVMName)

  Set colNICs = objVM.NetworkAdapters

  For each objPropNIC in colNICs
    objPropNIC.AttachToVirtualNetwork(objVMExt)
  Next

  Set objVM = Nothing
End Sub