title: Powershell list the dates between a range of dates.
body: <p>I am writing a script in <code>PowerShell</code> and I need to know the dates between a range of dates.</p>
  
  <p>The script is to automate reporting. Let's say there is a bunch of logged data, but the data only gets collected on weekdays, no weekends and no holidays. I FTP and collect the last 15 generations logged.</p>
  
  <p>With the script I open up the latest instance of the report in <code>Excel</code>. Once the workbook has opened up I read a cell which contains a date, that date will determine when the last time the report has been ran on. (Today's data however will not be accessible until tomorrow, so it is always 1 day behind.)</p>
  
  <p>When I than have that date, I use <code>Get-Date</code> to get the current date. 
  I need to know the dates between the current date and the date I read in from Excel. Afterwards I will need to see if any of the dates have fallen on a holiday, or if they have fell on the weekend. </p>
  
  <pre><code>$excelDate = $excel.Cells.Item(1489, 1).Value()
  $currentDate = Get-Date 
  </code></pre>
  
  <p>Let's say <code>$excelDate = "03/07/2014"</code> </p>
  
  <p>and <code>$currentDate = "03/14/2014"</code></p>
  
  <p>What I would like to get is 03/08/2014, 03/09/2014, 03/10/2014, 03/11/2014, 03/12/2014, 03/13/2014.</p>
  
  <p>Once I have those dates I can check to see if any of them were a holiday, and if they have fallen on a weekend. </p>
  
  <p>If they fell on a holiday I can subtract 1 day (or 2 days if the last day in the report fell on a Friday...I am still trying to figure out how I am going to do this.), and use a <code>switch</code> to <code>get-content</code> of the proper data before I begin to parse through and put it into <code>Excel</code>.</p>
  
  <p>So something like this: </p>
  
  <pre><code>switch($daysMissed)    
          {                                                       
             1  {Write-Host "The Report is currently up to date!!"                       }   
             2  {$data = get-content C:\Users\$userName\Desktop\Report\data\data.txt  }  
             3  {$data = get-content C:\Users\$userName\Desktop\Report\data\data2.txt } 
             4  {$data = get-content C:\Users\$userName\Desktop\Report\data\data3.txt }
             5  {$data = get-content C:\Users\$userName\Desktop\Report\data\data4.txt }
             6  {$data = get-content C:\Users\$userName\Desktop\Report\data\data5.txt }
             7  {$data = get-content C:\Users\$userName\Desktop\Report\data\data6.txt } 
             8  {$data = get-content C:\Users\$userName\Desktop\Report\data\data7.txt } 
             9  {$data = get-content C:\Users\$userName\Desktop\Report\data\data8.txt } 
             10 {$data = get-content C:\Users\$userName\Desktop\Report\data\data9.txt }
             11 {$data = get-content C:\Users\$userName\Desktop\Report\data\data10.txt }
  }
  </code></pre>
  
  <p>Once I have the proper data, I do a bunch of stuff within <code>Excel</code> and finish off that days report, then I would go <code>$daysMissed = $daysMissed - 1</code>. </p>
  
  <p>So my question is how exactly would I list the dates, between a range of dates?</p>
  
  <p>or, is there an easier way to do what I am doing? </p>
  
  <p>Thanks for the help!</p>