Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

$_.LastWriteTime format different for Write-Host & Write-Debug.

$
0
0

Windows 7, PowerShell v4.
Get-Culture = en-GB, Get-UICulture = en-US


Apparently I cannot change the UICulture to en-UK, to which every other setting in Control Panel is set.
So can somebody please explain this oddity, ie why are the first 2 below different?

Get-Item log.txt | foreach {
   Write-Debug $_.LastWriteTime                    #Write-Verbose & Warning produce the same.
1.-->   DEBUG: 12/14/2011 19:56:08             #US format.
   Write-Host  $_.LastWriteTime
2.-->               14/12/2011 19:56:08             #UK expected format.
   Write-Debug ("{0:G}" -f $_.LastWriteTime)  #Corrected to UK format!
3.-->   DEBUG: 14/12/2011 19:56:08
}


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images