Wednesday, July 16, 2014

Programmatically Detecting when a VM Changes State

Nice approach can be found here.
# WMI Query that specifies what events we will watch for
$Query = "Select * from __InstanceModificationEvent within 3 where TargetInstance ISA 'MSVM_ComputerSystem' `
          and TargetInstance.EnabledState <> PreviousInstance.EnabledState"
 
# Script block that will run whenever the event fires
[ScriptBlock]$Action = {
   $VMName = $Event.SourceEventArgs.NewEvent.TargetInstance.ElementName
 
   switch ($Event.SourceEventArgs.NewEvent.TargetInstance.EnabledState)
      {
        2 {$vmState = "running"}
        3 {$vmState = "turned off"}
        9 {$vmState = "paused"}
        6 {$vmState = "in a saved state"}
        10 {$vmState = "starting"}
        4 {$vmState = "stopping"}
        default {$vmState = "in an unknown state..."}
       }
 
   if ($Event.SourceEventArgs.NewEvent.TargetInstance.EnabledState -eq 1)
      {$vmState = $Event.SourceEventArgs.NewEvent.TargetInstance.OtherEnabledState}
 
   write-host "The virtual machine '$($vmName)' is now $($vmState)."}
 
# Register for the events
Register-WMIEvent -Query $Query -Action $Action -Namespace root\virtualization\v2
 
# To clean up - run "Get-EventSubscriber | Unregister-Event"

Tuesday, August 13, 2013

Hyper-V 2012 vs. vSphere 5.1

Hyper-V 2012 vs. vSphere 5.1
Interesting and unbiassed comparison. Ok, will see what VMware prepared with vSphere.Next (5.5?).

Tuesday, May 21, 2013

How to cleanup space on Windows Server 2008 R2

Useful post "WinSxS and reclaiming space" was written by Marcos Velez:

"The following command line will do everything that compcln.exe advertises, and it does so efficiently: 

dism /online /cleanup-image /spsuperseded /hidesp
For those interested in reading up some more on DISM, here is the technet reference:
http://technet.microsoft.com/en-us/library/dd744256(WS.10).aspx "



Wednesday, November 14, 2012

All VMware security guidelines in one place

Just for quick search :)

http://www.vmware.com/support/support-resources/hardening-guides.html

Update: vSphere 5.1 Hardening Guide Release Candidate has been announced