4/19/10

PowerShell List Dates Script

listDates '01-01' 7                       #01-01-2010
listDates '01-01' 7 'M-d'                 #1-1
listDates '01-01' 14 'ddd MM-dd'          #Fri 01-01
listDates '01-01-2011' 30                 #01-01-2011
listDates '01-01' 60 'MMM dd yyyy - ddd'  #Jan 01 2010 - Fri
function listDates($startDate, $daysCount, $format='MM-dd-yyyy')
{
  $startDate = [datetime]$startDate
  0..($daysCount-1) |
    %{
        $startDate.addDays($_).toString($format)  #console - show date
     }
}

No comments:

Post a Comment