The text and scripts for this post are adapted from the Virtual Server 2005 R2 Resource Kit.

Have you ever wanted to get a quick documentation of your Virtual Server 2005 R2 host configuration? What if you could do this using script and collect the information quickly help?

Using the VMVirtualServer.HostInfo property, you can gather and report on Virtual Server host information about processors, memory, the operating system, peripherals, drives, network adapters, and network addresses.

In the Virtual Server 2005 Resource Kit, we provide a sample script called HostInfo.vbs that can help you collect this information. HostInfo.vbs uses the HostInfo property to retrieve key information about the current host. Although some properties contain numbers or strings and can be used directly in WScript.Echo statements, others require additional processing. For example, the HostInfo.HostDrives property returns a collection of host drives. Once you have the collection, you can enumerate through each drive in the collection and obtain the name of the drive and the size of the drive. To get the size in megabytes, you must use the current drive in the collection as input to the HostInfo.GetHostDriveSize method as shown here:

For Each drive In drives
    WScript.Echo "Host Physical Drive : " & drive
    WScript.Echo "Host Drive Size : " & _
    objVS.HostInfo.GetHostDriveSize(drive) & " MB"
Next


The NetworkAdapters and NetworkAddresses properties also return collections that must be enumerated to obtain the correct information.

I updated the HostInfo.vbs script with another script in the book ConnectToRemoteVs.vbs to allow you to specify the host server name on the command line. If you want to get the information from the local machine, just pass localhost as the server name.

'-----------------------------------------------------------------
' HostInfo.vbs
'-----------------------------------------------------------------
Option Explicit


Dim objVS, objHost, strVersion, objArgs
Dim drives, drive, Nics, Nic, Addrs, Addr

'Retrieve the command line arguments
Set objArgs = WScript.Arguments

If objArgs.count = 0 then
   Wscript.echo " ERROR: Remote server not specified"
   Wscript.quit
End if

On Error Resume Next
Set objVS = CreateObject("VirtualServer.Application", objArgs(0))

If Err.number <> 0 Then
   Wscript.echo "Failed to connect to Virtual Server"
   Wscript.echo "Error Number=" & Err.Number & " Description=" & _
     Err.Description
   Wscript.quit
Else
   Wscript.echo "Successfully connected to Virtual Server" & _ objArgs(0)
   Err.Clear
   On Error GoTo 0
End if

Set objHost = objVS.HostInfo

WScript.Echo "------------------------------------------------------------"
WScript.Echo "Processor information"
WScript.Echo "------------------------------------------------------------"
WScript.Echo "Logical processor count : " & objHost.LogicalProcessorCount
WScript.Echo "Physical processor count : " & objHost.PhysicalProcessorCount
WScript.Echo "Processor features : " & objHost.ProcessorFeaturesString
WScript.Echo "Processor manufacturer : " & objHost.ProcessorManufacturerString
WScript.Echo "Processor speed : " & objHost.ProcessorSpeedString
WScript.Echo "Processor version : " & objHost.ProcessorVersionString
WScript.Echo "------------------------------------------------------------"
WScript.Echo " Memory information"
WScript.Echo "------------------------------------------------------------"
WScript.Echo "Memory available : " & objHost.MemoryAvailString
WScript.Echo "Memory total : " & objHost.MemoryTotalString
WScript.Echo "------------------------------------------------------------"
WScript.Echo " OS information"
WScript.Echo "------------------------------------------------------------"
WScript.Echo "Operating system : " & objHost.OperatingSystem
WScript.Echo "OS service pack : " & objHost.OSServicePackString
WScript.Echo "OS version : " & objHost.OSVersionString
WScript.Echo "------------------------------------------------------------"
WScript.Echo " Peripheral information"
WScript.Echo "------------------------------------------------------------"
WScript.Echo "Parallel port : " & objHost.parallelPort
WScript.Echo "Serial port : " & objHost.SerialPorts
WScript.Echo "------------------------------------------------------------"

WScript.Echo " Drive information"
WScript.Echo "------------------------------------------------------------"
drives = objVS.HostInfo.HostDrives
For Each drive In drives
   WScript.Echo "Host Physical Drive : " & drive
   WScript.Echo "Host Drive Size : " & _
   objVS.HostInfo.GetHostDriveSize(drive) & " MB"
Next
WScript.Echo "------------------------------------------------------------"
WScript.Echo " Network Adapter information"
WScript.Echo "------------------------------------------------------------"
Nics = objVS.HostInfo.NetworkAdapters
For Each Nic In Nics
   WScript.Echo "Network Adapter : " & Nic
Next
WScript.Echo "------------------------------------------------------------"
WScript.Echo " Network Address information"
WScript.Echo "------------------------------------------------------------"
Addrs = objVS.HostInfo.NetworkAddresses
For Each addr In Addrs
   WScript.Echo "Host Address : " & Addr
Next

Now this script requires you to provide a server name on the command line and you must have administrative rights on the remote host to run it.

I left you something to do, modify the script to save the information to a file.  The resource kit also shows you how to do that. ;-)

Let me know if this was helpful and if you want more useful scripts, please go buy a copy of the resource kit and you will find over 40 sample scripts like this included.