Hello!

Often I write a small piece of PowerShell that I will create and then lose and forget about before needing it again sometime in the future. So to that end I’ve decided to start sharing here for myself as much as anyone else.

Today’s snippet is iterating over a DateTime and adding a time span to the base DateTime.

$iterate = 24
[datetime]$baseDateTime = "2016-06-09 10:00:00.000"

for($i=0
$i -le $iterate
$i++)
{

$ts = New-TimeSpan -Hours 1
$baseDateTime = $baseDateTime + $ts
$baseDateTime
}