1. #Add-PSSnapIn VMware.VimAutomation.Core
  2. # Connect to vCenter
  3. $VC = Connect-VIServer (Read-Host "Enter vCenter server")
  4. # Enter the KB#
  5. $HotFixID = (Read-Host "Enter KB#")
  6. Write-Host
  7. # Get all VM�s with powerstate = PoweredOn
  8. $VMS = Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Sort Name
  9. ForEach ($VM in $VMS)
  10. {
  11. # Process only Windows Server VM�s
  12. if ($VM.Guest.OSFullName -match "Microsoft Windows Server*")
  13. {
  14. # Get all the info using WMI
  15. $results = get-wmiobject -class "Win32_QuickFixEngineering"
  16. -namespace "root\CIMV2" -ComputerName $VM
  17.  
  18. # Loop through $results and look for a match then output to screen
  19. foreach ($objItem in $results)
  20. {
  21. # Do the match
  22. if ($objItem.HotFixID -match $HotFixID)
  23. {
  24. write-host $objItem.CSName
  25. write-host "Hotfix "$HotFixID" installed"
  26. write-host
  27. }
  28. }
  29. }
  30. }
  31. # Disconnect from vCenter
  32. Disconnect-VIServer -Confirm:$False
  33.  

Last Updated (Wednesday, 13 May 2009 15:51)