Windows PowerShell Home
export-counter cmdlet exports date in wrong timestamp format when written to a csv file
6/28/2011 3:41:29 PM
User(s) can reproduce this bug
the export-counter cmdlet writes the sampling timestamp column in the US format (MM/dd/yyyy) to a csv file - as viewed in Notepad - regardless of which culture is currently in influence. This creates many issues with importing/using the data. (other cmdlets such as get-counter and get-date utilize the current culture correctly and subsequently return the correct date format).
Is this a bug or by design? If by design, where is this... exceptional feature documented and what's the rationale behind such design? Note in the reproduction steps that the get-counter statement returns the correct date format (
How often does this happen?
Have you seen this problem before in this product?
I don't know if this issue existed previously
[System.Globalization.CultureInfo] $culture = "en-NZ"
[System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
# List of counters
$_lstCounters = get-content c:\psscripts\counters.txt
$_path = "c:\Counters\CounterResults" + $_server + ".csv"
$resultSet = Get-Counter -counter $_lstCounters -computername $_server -maxsamples 1
Export-Counter -inputobject $resultSet -maxsize 1073741824 -path $_path -force -fileformat csv
29/06/2011 10:37:50 a.m.
to post a comment.
Please enter a comment.
on 4/10/2012 at 2:09 PM
ran into the same problem
Using get-counter to get cpu and memory stats from the host. I then add the results as a string/line in a custom csv file.
When I read the csv file back and turn the timestamp value back into a [time] object the months and days are mixed up.
Using Powershell 3.0 preview 2
on 3/19/2012 at 3:59 PM
Does anyone from Microsoft actually check these bug reports?
to post a workaround.
Please enter a workaround.
© 2014 Microsoft