PowerShell Snippet #1


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"

$i -le $iterate

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

Author: Richie Lee

Full time computer guy, part time runner. Full time Dad, part time blogger. Knows a thing or two about Pokémon. Knows too much about SQL Agent. Writer of fractured sentences. Maker of the best damn macaroni cheese you've ever tasted.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s