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
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 argumentsSet objArgs = WScript.Arguments
If objArgs.count = 0 then Wscript.echo " ERROR: Remote server not specified" Wscript.quitEnd if
On Error Resume NextSet 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.quitElse Wscript.echo "Successfully connected to Virtual Server" & _ objArgs(0) Err.Clear On Error GoTo 0End if
Set objHost = objVS.HostInfo
WScript.Echo "------------------------------------------------------------"WScript.Echo "Processor information"WScript.Echo "------------------------------------------------------------"WScript.Echo "Logical processor count : " & objHost.LogicalProcessorCountWScript.Echo "Physical processor count : " & objHost.PhysicalProcessorCountWScript.Echo "Processor features : " & objHost.ProcessorFeaturesStringWScript.Echo "Processor manufacturer : " & objHost.ProcessorManufacturerStringWScript.Echo "Processor speed : " & objHost.ProcessorSpeedStringWScript.Echo "Processor version : " & objHost.ProcessorVersionStringWScript.Echo "------------------------------------------------------------"WScript.Echo " Memory information"WScript.Echo "------------------------------------------------------------"WScript.Echo "Memory available : " & objHost.MemoryAvailStringWScript.Echo "Memory total : " & objHost.MemoryTotalStringWScript.Echo "------------------------------------------------------------"WScript.Echo " OS information"WScript.Echo "------------------------------------------------------------"WScript.Echo "Operating system : " & objHost.OperatingSystemWScript.Echo "OS service pack : " & objHost.OSServicePackStringWScript.Echo "OS version : " & objHost.OSVersionStringWScript.Echo "------------------------------------------------------------"WScript.Echo " Peripheral information"WScript.Echo "------------------------------------------------------------"WScript.Echo "Parallel port : " & objHost.parallelPortWScript.Echo "Serial port : " & objHost.SerialPortsWScript.Echo "------------------------------------------------------------"
WScript.Echo " Drive information"WScript.Echo "------------------------------------------------------------"drives = objVS.HostInfo.HostDrivesFor Each drive In drives WScript.Echo "Host Physical Drive : " & drive WScript.Echo "Host Drive Size : " & _ objVS.HostInfo.GetHostDriveSize(drive) & " MB"NextWScript.Echo "------------------------------------------------------------"WScript.Echo " Network Adapter information"WScript.Echo "------------------------------------------------------------"Nics = objVS.HostInfo.NetworkAdaptersFor Each Nic In Nics WScript.Echo "Network Adapter : " & NicNextWScript.Echo "------------------------------------------------------------"WScript.Echo " Network Address information"WScript.Echo "------------------------------------------------------------"Addrs = objVS.HostInfo.NetworkAddressesFor Each addr In Addrs WScript.Echo "Host Address : " & AddrNext
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.