VMware Cloud Community
chakoe
Enthusiast
Enthusiast

Read VM - Display Resolution

Hi,

is it possible to read the VM´s display-resolution usin PowerCLI ?

Thx

Chakoe

0 Kudos
5 Replies
nirvy
Commander
Commander

Hi Chakoe

You can use this in PowerCLI

$vm = Get-VM -Name <vm_name>

$vm.Guest.ExtensionData.Screen

Returns:


              Width              Height DynamicType         DynamicProperty
              -----              ------ -----------         ---------------
               1024                 768

0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

works fine, but i´m missing the VM-Name in the first column of the table...

And is it possible to set the Resolution within an script?

thx

Chakoe

0 Kudos
nirvy
Commander
Commander

I personally don't know of a way to do it using only PowerCLI/PowerShell,  I think you will need to use inline C#, which would make it something of a pain to do.

See here for more info:

http://blogs.technet.com/b/heyscriptingguy/archive/2010/07/07/hey-scripting-guy-how-can-i-change-my-...

You could invoke that script in the guest using Invoke-VMScript from PowerCLI.

Oh, also you don't need to use ExtensionData to get the screen resolution, instead your code can just be: $vm.Guest.ScreenDimensions

0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

and how do i add the column " VM-Name" to the output-table?

0 Kudos
ykalchev
VMware Employee
VMware Employee

Try this simple script:


Get-VM | % {
     $row = "" | select
VMName, Width, Height
     $row.VMName = $_.Name
     $row.Width = $_.Extensiondata.Guest.Screen.Width
     $row.Height = $_.Extensiondata.Guest.Screen.Height
     $row
}

Regards,

Yasen

Message was edited by: ykalchev

Yasen Kalchev, vSM Dev Team
0 Kudos