SCVMM- Part7 (PowerShell)


As you should be aware SCVMM like Exchange 2007 is based on PowerShell (previously known as "Monad").  This enables you to perform every action that the GUI does from the command line and in some cases more.  PowerShell is a pre-requisite for SCVMM and is installed during the setup.


You can start PowerShell from a command prompt by typing:- "PowerShell", or there is a shortcut on the SCVMM Server menu - START-Microsoft SCVMM-Windows PowerShell - VMM 


I'd suggest you use the latter as the SCVMM specific cmdlets (not sure of the precise term here) are loaded and available.


If you need a primer on PowerShell:



Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell or
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx


 


GET_VM


The Get-VM command returns information about the SCVMM server and the Virtual Server hosts and guests, the syntax at is most simple would be:



get-vm


This will prompt you to enter the name of the SCVMM server, so it could be easier just to enter



get-vm -server <server name>


Where <server name> is your SCVMM host, this will return the following data (I've only shown one VM to save space, and replaced some data with "xxxx", all VM's will be listed by this command).  Remember all syntax examples I give you need to be entered on a single line. The information returned is:



Location               : I:\VHD\Win2003_Ent_SCSI_SYSPREP
VMId                   : {AD75AD0C-xxxxxx-xxxxx-xxxxx-xxxxx}
HostGroupPath          : Managed Computers\Infrastructure Hosts\hotgold.euro
                         soft.com\2003
VMState                : Missing
VMStateString          : Missing
CPUUtilization         : 23
PerfCPUUtilization     : 0
PerfDiskBytesRead      : 0
PerfDiskBytesWrite     : 0
PerfNetworkBytesRead   : 0
PerfNetworkBytesWrite  : 0
OperatingSystem        : unknown
VMAddition             : VM Addition Not Installed
ProcessorCount         : 1
Memory                 : 256
UndoDisksEnabled       : False
ProcessorType          :
ProcessorSpeed         : 0
ExpectedCPUUtilization : 100
DiskIO                 : 0
NetworkUtilization     : 0
Priority               : 5
CPUReserve             : 100
CPUMax                 : 100
DVDDrives              : {Virtual CD / DVD drive (Z:)}
VirtualHardDisks       : {2003}
ShareSCSIBus           :
NetworkAdapters        : {External Network (Intel(R) PRO_1000 MT Network Con
FloppyDrive            : 2003
HostId                 : 53f0e24axxxxxxxxxxxxxxxxx
HostType               : Host
HostName               : hotgold.xxx.xxx.xxxx.xxxx.com
VMHost                 : hotgold.xxxx.xxxx.xxxx.com
LibraryServer          :
Owner                  : unknown
OwnerSid               :
ObjectType             : VM
Accessibility          : Public
Name                   : 2003
Description            : auto-discovered
CreationTime           : 10/08/2006 09:20:43
ModifiedTime           : 17/08/2006 09:23:23
AccessedTime           : 17/08/2006 09:23:23
MarkedForDeletion      : False
MostRecentTask         :
ServerConnection       : Microsoft.VirtualManager.Monad.Remoting.ServerConne
ID                     : 7984fc54xxxxxxxxxxxxxxxxx


So this list might give you all the infomation you would need, but you might want to filter the data, this example does just that, you may wish to look up what the "Format-List" command does in the primer links I mentioned above:



get-vm -server hotnas | format-list vmstate



VMState : Stored
VMState : PowerOff
VMState : PowerOff
VMState : PowerOff
VMState : Running
VMState : Unsupported


However the Vmstate information on it's own isn't that useful so we need to build up the query, for example:



get-vm -server hotnas | format-list hostname,name,vmstate



HostName : hotnas.xxxx.xxxx.xxxx.com
Name     : Clwatson-lhs1
VMState  : Stored


HostName : hotgold.xxxx.xxxx.xxxx.com
Name     : eiger
VMState  : PowerOff


HostName : hotgold.xxxx.xxxx.xxxx.com
Name     : LHS2
VMState  : PowerOff


HostName : hotgold.xxxx.xxxx.xxxx.com
Name     : infmom
VMState  : PowerOff


You can of course return any data that you wish to filter by changing my example queries to include the fields you are interested in, the output of the command get-vm -server <server name> in the left column, gives you the available options, these are the current ones (as of Beta 1):


 


Location               :
VMId                   :
HostGroupPath          :


VMState                :
VMStateString          :
CPUUtilization         :
PerfCPUUtilization     :
PerfDiskBytesRead      :
PerfDiskBytesWrite     :
PerfNetworkBytesRead   :
PerfNetworkBytesWrite  :
OperatingSystem        :
VMAddition             :
ProcessorCount         :
Memory                 :
UndoDisksEnabled       :
ProcessorType          :
ProcessorSpeed         :
ExpectedCPUUtilization :
DiskIO                 :
NetworkUtilization     :
Priority               :
CPUReserve             :
CPUMax                 :
DVDDrives              :
VirtualHardDisks       :
ShareSCSIBus           :
NetworkAdapters        :
FloppyDrive            :
HostId                 :
HostType               :
HostName               :
VMHost                 :
LibraryServer          :
Owner                  :
OwnerSid               :
ObjectType             :
Accessibility          :
Name                   :
Description            :
CreationTime           :
ModifiedTime           :
AccessedTime           :
MarkedForDeletion      :
MostRecentTask         :
ServerConnection       :
ID                     :


More useful SCVMM Powershell commands will follow...


 


UPDATE:
For beta1 there is no PowerShell documentation nor is the the powershell interface directly supported. 
We'll support the powershell interface in beta 2 and the final release of
SCVMM

Comments (2)

  1. Anonymous says:

    Clive Watson has been testing the new System Center Virtual Machine Manager Beta 1 and he has posted…

Skip to main content