לקראת המעבר לשעון חורף רצינו לוודא שהגדרות השעון ב – ESX-ים תקינות ולא יהיו לנו הפתעות במעבר.
אז כתבתי סקריפט קטן שרץ מול ה – vCenter ,מוציא כמה פרמטרים של שרתי ה – ESX ושומר את התוצאות בקובץ csv.
פלט לדוגמא:
כך צריך להיראות שרת תקין לפני המעבר. אחרי המעבר ה – TZ_Description יתחלף ל – IST וה – GmtOffset_Sec ל – 7200.
הנה הסקריפט עצמו (אל תשכחו להחליף את vcenter_name בשם ה – vCenter שלכם):
# Loads VMware's PowerCLI PowerShell cmdlets if necessary [void](Get-PSSnapin VMWare.VimAutomation.Core -ErrorVariable getVmwareSnapinErr 2> $null) if ($getVmwareSnapinErr.Count -gt 0) { Add-PSSnapin VMware.VimAutomation.Core } # vCenter to connect to $vCenter_name = "vcenter_name" # Path to the report file $report_file = "C:\time_report.csv" # connect to vCenter Connect-VIServer $vCenter_name # variable to store the output $report = @() # get list of all host view objects $host_views = Get-VMHost | Sort Name | Get-View # this loop runs on all host view objects foreach ($host_view in $host_views) { # create custom object $my_obj = "" | select ESX, Time, Date, Timezone, TZ_Description, GmtOffset_Sec # populate Name field $my_obj.ESX = $host_view.Name $host_time_view = Get-View $host_view.ConfigManager.DateTimeSystem # populate GmtOffset field $my_obj.GmtOffset_Sec = $host_time_view.DateTimeInfo.TimeZone.GmtOffset # get current host time $host_date_time = $host_time_view.QueryDateTime().AddSeconds($my_obj.GmtOffset_Sec) # populate Time field $my_obj.Time = $host_date_time.ToLongTimeString() # populate Date field $my_obj.Date = $host_date_time.ToShortDateString() # populate Timezone field $my_obj.Timezone = $host_time_view.DateTimeInfo.TimeZone.Name # populate TZ_Description field $my_obj.TZ_Description = $host_time_view.DateTimeInfo.TimeZone.Description # add current host to the output array $report += $my_obj } # write output to file $report | Export-Csv -NoTypeInformation -Path $report_file # disconnect from vCenter Disconnect-VIServer -Confirm:$false
לינק להורדת הסקריפט כקובץ (שנו את הסיומת ל – ps1):
מעבר חלק ושנה טובה!
מיכאל.