So I was updating my script to read DNS debug logs. I had gotten some comment’s on it in the technet gallery, and github since Technet Galleries closed. So I wanted to include all in the script for easier usage.

This is when I realized how many variations there are to the ShortDatePattern used in the local Cultures. Microsoft uses the local culture in the DNS debug log, big sadness. So how many cultures are there?

PS C:\Users\virot> [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::InstalledWin32Cultures)|Measure-Object

Count : 428
Average :
Sum :
Maximum :
Minimum :
Property :

PS C:\Users\virot

Okey with 428 different possible cultures I don’t think I will go through them one by one. So lets just list all cultures and their ShortDatePattern. And see if we see anything.

PS C:\Users\virot> [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::InstalledWin32Cultures)|select Name| ForEach-Object {Add-Member -Name 'DateTimeFormat' -Force -PassThru -InputObject $_ -MemberType NoteProperty -Value ([System.Globalization.CultureInfo]::new($_.name).DateTimeFormat.ShortDatePattern)}

Name           DateTimeFormat
----           --------------
               MM/dd/yyyy
af             yyyy-MM-dd
af-ZA          yyyy-MM-dd
am             dd/MM/yyyy
am-ET          dd/MM/yyyy
ar             dd/MM/yy
ar-AE          dd/MM/yyyy
ar-BH          dd/MM/yyyy
ar-DZ          dd-MM-yyyy
ar-EG          dd/MM/yyyy
ar-IQ          dd/MM/yyyy
ar-JO          dd/MM/yyyy
ar-KW          dd/MM/yyyy
ar-LB          dd/MM/yyyy
ar-LY          dd/MM/yyyy
ar-MA          dd-MM-yyyy
ar-OM          dd/MM/yyyy
ar-QA          dd/MM/yyyy
ar-SA          dd/MM/yy
ar-SY          dd/MM/yyyy
ar-TN          dd-MM-yyyy
ar-YE          dd/MM/yyyy
arn            dd-MM-yyyy
arn-CL         dd-MM-yyyy
as             dd-MM-yyyy
as-IN          dd-MM-yyyy
az             dd.MM.yyyy
az-Cyrl        dd.MM.yyyy
az-Cyrl-AZ     dd.MM.yyyy
az-Latn        dd.MM.yyyy
az-Latn-AZ     dd.MM.yyyy

That is just the ones beginning with an A. This wont do, my eyes will hurt. Lets get Powershell to analyze this instead. I will be using the Group-Object to do the counting.

PS C:\Users\virot> [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::InstalledWin32Cultures)|select Name| ForEach-Object {Add-Member -Name 'DateTimeFormat' -Force -PassThru -InputObject $_ -MemberType NoteProperty -Value ([System.Globalization.CultureInfo]::new($_.name).DateTimeFormat.ShortDatePattern)}|Group-Object DateTimeFormat -NoElement|sort count -Descending

Count Name
----- ----
  111 dd/MM/yyyy
   49 dd.MM.yyyy
   46 d/M/yyyy
   39 yyyy-MM-dd
   38 dd-MM-yyyy
   18 dd-MM-yy
   16 M/d/yyyy
   15 yyyy/M/d
   15 yyyy/MM/dd
   15 d.M.yyyy
   12 d/MM/yyyy
    9 d.M.yyyy.
    6 dd/MM/yy
    6 dd.MM.yyyy.
    6 dd.MM.yy
    5 d-M-yyyy
    3 MM/dd/yyyy
    2 dd.MM.yy 'ý.'
    2 d. MM. yyyy
    2 yyyy-M-d
    2 d.MM.yyyy
    2 d.M.yyyy 'г.'
    2 yyyy. MM. dd.
    2 d. M. yyyy
    2 dd.M.yyyy
    2 d-MMM yy
    1 d/M/yy


PS C:\Users\virot>

So we see that there are a few different formats. I would say that you want to allow for atleast the ones with a count above 10.