Feb 5, 2010 at 5:42 PM
Edited Feb 7, 2010 at 1:14 PM
Very nice. I'm just looking at the localization and getting a bit lost in the $BeginTime $Global:BeginTime variables however as relog uses "MM/dd/yyyy hh:mm:ss" I think we might be better
off using that throughout the script and then just converting to localized for display purposes. This is compounded by the fact that the wizard passed a localized date to the command line so in the UK we get "29/01/2010 20:14:22"
To that end have converted the lines below to support this and removed "Function ConvertToTwentyFourHourTime" as I don't think we need it (please feel free to correct me). This should mean
that the wizard works with local date formats and if you use the command line you can actually use local time format as it gets converted at runtime.
If ($BeginTime -ne $null)
$global:BeginTime = ([datetime]::parseexact($BeginTime,$global:sDateTimePattern,$null)).tostring("MM/dd/yyyy HH:mm:ss")
If ($EndTime -ne $null)
$global:EndTime = ([datetime]::parseexact($EndTime,$global:sDateTimePattern,$null)).tostring("MM/dd/yyyy HH:mm:ss")
Also updated (to make chart x axis localised)
[Void] $SeriesOfCounterValues.Points.AddXY($aDateTimes[$b], $aValues[$b])
[Void] $SeriesOfCounterValues.Points.AddXY(([datetime]$aDateTimes[$b]).tostring($global:sDateTimePattern), $aValues[$b])
I had to update "ConvertAnalysisIntervalIntoHumanReadableTime" to use the $Global
'begintime' and 'endtime' and added "$sInterval=$null" otherwise it fell foul of the "Set-StrictMode"
$Global:BeginTime = Get-Date
$Global:EndTime = $Global:BeginTime.AddSeconds($TimeInSeconds)
$DateDifference = New-TimeSpan -Start ([DateTime]$Global:BeginTime) -End ([DateTime]$Global:EndTime)
If ($DateDifference.Seconds -gt 0)
Finally I updated
"$global:BeginTime = $BeginTime" just under "$global:sDateTimePattern = (get-culture).datetimeformat.ShortDatePattern + " " + (get-culture).datetimeformat.LongTimePattern" to "$global:BeginTime = $null" just so
we are sure it's set to something but we don't confuse the localization.
p.s. hope you don't mind me tinkering in the code like this.