Quantcast
Viewing all articles
Browse latest Browse all 293210

Re: Working script but need help tweaking

I could reproduce the problem with a Windows 2008 64-bit VM.

The script didn't test for that OS. The following updated version should do the trick

 

 

# Create Server List for Patching  
$report = @() $vms = Get-Folder Folder, Folder1, Folder2, Folder3 | Get-VM
foreach
($vm in $vms){     $row = "" | Select Name, State, Status, Host, CPU_Allocated, RAM_Allocated, LastReboot, LastPatchApplied, LastPatchDate, Rebooted, Issues     $row.Name = $vm.Name     $row.State = $vm.PowerState     $row.Status = $vm.ExtensionData.Summary.OverallStatus     $row.Host = $vm.VMHost     $row.CPU_Allocated = $vm.numcpu     $row.RAM_Allocated = $vm.memorymb     if($row.State -eq "PoweredOn"){         $row.LastReboot = [System.Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject win32_operatingsystem -cn $row.Name).lastbootuptime)         $lastPatch = Get-WMIObject Win32_QuickFixEngineering -ComputerName $row.Name |         where {($_.psBase.properties["InstalledOn"].Value).Length -gt 0} |         Sort-Object -Property {             if("winNetStandardGuest","WinLonghornGuest","winLonghorn64Guest" -contains $vm.Guest.GuestId){                 $_.InstalledOn             }else{                 [datetime]($_.psbase.Properties["InstalledOn"].Value)             }         } | Select -Last 1
       
if("winNetStandardGuest","WinLonghornGuest","winLonghorn64Guest" -contains $vm.Guest.GuestId){             $row.LastPatchDate = $lastPatch.InstalledOn         }         else{             $row.LastPatchDate = $lastPatch.psbase.Properties["InstalledOn"].Value         }         $row.LastPatchApplied = $lastPatch.HotfixId     }     $row.Rebooted = "YES/NO"
   
$row.Issues = "YES/NO"
   
$report += $row
}
$report
# End the Session on the Server

Viewing all articles
Browse latest Browse all 293210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>