International date format

Nov 28, 2011 at 11:03 AM

  Can anyone confirm if this is module problem or is it general Powershell problem with dates. If I dont specify Under the "Region and Language", Formats tab, that the date Format is "English (United States)"(M/d/yyyy) then I get error when I do this:

today is 28 november 2011

PS C:\> Get-CertificationAuthority | Get-IssuedRequest -filter "CertificateTemplate -eq Webserver","NotAfter -le $((Get-Date).AddDays(46))"
WARNING: Specified pattern 'NotAfter -le 01/13/2012 13:56:29' is not valid!


Nov 28, 2011 at 10:14 PM
Edited Nov 28, 2011 at 10:16 PM

this is neither PowerShell or my module issue. The issue occurs when client (where you run the module) and CA server uses different and uncompatible date/time formats. As a workaround you can try this example:

$Date = (Get-Date).AddDays(46).Tostring("MM.dd.yyyy hh:mm:ss")
Get-CertificationAuthority | Get-IssuedRequest -filter "CertificateTemplate -eq Webserver","NotAfter -le $Date"
Nov 29, 2011 at 6:53 AM

 Thank you for clarification. At least I know now what the problem is because the time format on my workstation is different from CA. Fortunately I don't run the scheduled script on my workstation but on the server itself and the problem isn't relevant there. But the issue confused me because I tested the script on my workstation. The workaround didn't help either, it just won't work when formats are different on the client and CA server.