For those folks new to PowerShell you need to wrap your brain around the object concept. It is fundamental to understanding (grok-ing actually) tons of stuff.
In the Hyper-V cmdlet set in Windows 8 if you ‘get’ a VM object ( $vm = Get-VM –Name Foo) you can simply type of object out and see its properties ( $vm ).
PS C:\Users\Administrator> $vm
Name State CPUUsage(%) MemoryAssigned(M)
---- ----- ----------- -----------------
BrianEhDC.BrianEh.local Off 0 0
Now, lets say that Admin Joe or XenDesktop brokering just turned on that VM that you have captured as your object. Type its properties again.
PS C:\Users\Administrator> $vm
Name State CPUUsage(%) MemoryAssigned(M)
---- ----- ----------- -----------------
BrianEhDC.BrianEh.local Running 4 512
Notice that it is now running. And you didn’t have to re-query to get that.
As stated by the Feature lead for the Hyper-V cmdlets: “You get it for free” – In other words you didn’t have to do extra work to see that a property changed. You did not have to do Get-VM again.
Cool!
No comments:
Post a Comment