|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
hi all
how can i get the ip address of a vm using virtual server com interface? i can only do this so far... string name = CmdArgs[paramIndex]; VMVirtualMachine machine = myVS.FindVirtualMachine(name); IVMNetworkAdapterCollection adapters = machine.NetworkAdapters; foreach (IVMNetworkAdapter ada in adapters) { output("ada"); output(ada.EthernetAddress); output(ada.VirtualMachine.Name); output("net"); VMVirtualNetwork net = ada.virtualNetwork; output(net.HostAdapter); output(net.Name); output("dhcp"); VMDHCPVirtualNetworkServer dhcp = net.DHCPVirtualNetworkServer; output(dhcp.DefaultGatewayAddress); output(dhcp.DNSServers); } |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Assuming the VM is running, and is a Windows machine you can probably use a
script like this to obtain the IP Address strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set IPConfigSet = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) WScript.Echo IPConfig.IPAddress(i) Next End If Next "i am a ramone" <pythonow@gmail.com> wrote in message news:01ac98fc-0b8d-431e-b0dd-1c4f1a5b0f43@p69g2000hsa.googlegroups.com... > hi all > how can i get the ip address of a vm using virtual server com > interface? > > i can only do this so far... > string name = CmdArgs[paramIndex]; > VMVirtualMachine machine = > myVS.FindVirtualMachine(name); > IVMNetworkAdapterCollection adapters = > machine.NetworkAdapters; > foreach (IVMNetworkAdapter ada in adapters) > { > output("ada"); > output(ada.EthernetAddress); > output(ada.VirtualMachine.Name); > output("net"); > VMVirtualNetwork net = ada.virtualNetwork; > output(net.HostAdapter); > output(net.Name); > output("dhcp"); > VMDHCPVirtualNetworkServer dhcp = > net.DHCPVirtualNetworkServer; > output(dhcp.DefaultGatewayAddress); > output(dhcp.DNSServers); > > } |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Thanks for the vbscript u given. Actually I am programming in C# and
using the Virtual Server COM interfaces, would u please point how to finish the work by using the Virtual Server COM interfaces in C#? thank u ![]() |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
en... now I am at the server side, I try to control the vm using the
C#, I want to get the vm ip, I have already got the vm's name. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
I'm not a C# programmer, but I found on the following web site
(http://www.howtogeek.com/howto/progr...hostname-in-c/) this after a short search string howtogeek = "www.howtogeek.com"; IPAddress[] addresslist = Dns.GetHostAddresses(howtogeek); foreach (IPAddress theaddress in addresslist) { Console.WriteLine(theaddress.ToString()); } "i am a ramone" <pythonow@gmail.com> wrote in message news:521d63d5-8903-41c2-bf2e-daea2be39773@e25g2000prg.googlegroups.com... Thanks for the vbscript u given. Actually I am programming in C# and using the Virtual Server COM interfaces, would u please point how to finish the work by using the Virtual Server COM interfaces in C#? thank u ![]() |
|
![]() |
| Outils de la discussion | |
|
|