Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Increment hours by 30 minutes 20 times in Powershell

I have to create multiple job in my app. These jobs should be separated by 30 minutes apart starting at 17:00. My dilemma how to get 20 times in hour and minutes ( HH:MM) format starting at 17:00 ?? Onces i have those times , i can loop all jobs 30 minutes apart.
Thank you

So far i have tried

$ts = New-TimeSpan -Hours 17 -Minutes 00

But adding minutes to $ts not working

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

PS F:\> $ts.AddMinutes(30)
Method invocation failed because [System.TimeSpan] does not contain a method named 'addminutes'.
At line:1 char:1
+ $ts.AddMinutes(30)
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

>Solution :

You can simply add a new timespan:

$newts = $ts + (New-TimeSpan -Minutes 30)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading