2

Running:

get-vm -server hyperv
get-vm -server hyperv | format-table -AutoSize

Result in a 5 column output with data in all 5 columns as expected.

Running:

get-vm -server hyperv | select VMElementName,State,Host | format-table -AutoSize
get-vm -server hyperv | format-table -Property VMElementName,State,Host -AutoSize

Results in a 3 column output with data in only the VMElementName column. Any attempt to reduce the number of columns results in all but the VMElementName column is empty. Changing order has no effect. Selecting any single column makes no difference. Only the VMElementName column contains data.

How do I get the rest of the data to be shown?

2 Answers 2

3

Using the Hyper-V module from Server 2008 R2, Get-VM returns objects of the type System.Management.ManagementObject#root\virtualization\Msvm_ComputerSystem. In other words, these are WMI based objects, where the WMI class is Msvm_ComputerSystem.

Your issue is that this object does not contain some of the properties you are asking for.

If you do a Get-VM | Get-Member, you can see the actual properties available, I think what you want is

Get-VM | FT Elementname, statusdescriptions,pscomputername

Elementname                             statusdescriptions                  PSComputerName
-----------                             ------------------                  --------------
Lync - SE                               {Operating normally}                    COOKHAM8
Lync - QMS                              {Operating normally}                    COOKHAM8
Lync - DC                               {Operating normally}                    COOKHAM8
Lync - SPS2010                          {Operating normally}                    COOKHAM8
DEV1 - win7+Dev tools                   {Operating normally}                    COOKHAM8
S1.Cookham/Net (Srv2012)                {Operating normally}                    COOKHAM8
SQL2012                                 {Operating normally}                    COOKHAM8
W8.Cookham.Net(w8 RTM)                  {Operating normally}                    COOKHAM8
Lync - EXUM                             {Operating normally}                    COOKHAM8
SQL2008                                 {Operating normally}                    COOKHAM8
Sign up to request clarification or add additional context in comments.

2 Comments

I see. So the Get-VM column names are static aliases for WMI properties, and I need to reference the underlying properties in FT. Thank you for the example.
In most cases (unless you change it using a hash table), a table/list heading is the name of the underlying object's property name. But not always. Bug glad it worked for you!
1

Empty Format-Table columns usually indicate that the associated property doesn't exist or the value for each item is $null or an empty string. If I look at the output of Get-VM on Windows 8 (where I have one hyper-v VM created), I don't see those properties. You can see what properties are available using Get-Member like so:

Get-VM -server hyperv | Get-Member

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.