Welcome to MSDN Blogs Sign in | Join | Help

Looking at the GuestOS.ComputerName property

Virtual Server 2005 R2 SP1 added a few new bells and whistles to the COM API.  One of these is the GuestOS.ComputerName property.  This property allows you to get the network name of the virtual machine through the COM API.

Option Explicit
 
Dim vs, vm, vmName, vmGuestName
 
vmName = "Windows NT 4.0 CVS Server"
 
'Connect to Virtual Server 
Set vs = CreateObject("VirtualServer.Application")
 
'Connect to VM
Set vm = vs.FindVirtualMachine(vmName)
 
vmGuestName = vm.GuestOS.ComputerName 
 
WScript.Echo "The virtual machine " & Chr(34) & vmName & Chr(34)
WScript.Echo "Has a guest operating system configured with a network name of " & Chr(34) & vmGuestName & Chr(34)

The great thing about this is that if you want to automate a process that connects to a virtual machine over the network - and be able to handle random network names - then this will allow you to do it.

Cheers,
Ben

Published Thursday, July 05, 2007 10:53 PM by Virtual PC Guy

Comments

Saturday, July 07, 2007 3:54 AM by Jonathan

# re: Looking at the GuestOS.ComputerName property

In vbscript, use can use:

   WScript.Echo "The virtual machine """" & vmName & """"

In other words, to quote a double quote, you can use double-double-quotes. Hihi.

New Comments to this post are disabled
 
Page view tracker