PowerShell Get-TimeMachine?!

Well, I know what you’re thinking, it is just click bait. But I want to assure you it is possible.

new-timespanYou could create this into a function but the magic is in the details of this one.

“New-TimeSpan” is a tool that has existed since 2.0 and before you start-sleep ever again, consider the possibilities if you can truly calculate the duration of start-sleep dynamically!

So I stumbled across this only due to the need to simulate a scheduled task/job quickly in an environment I had not the local privileges to ensure that I could create a scheduled job.

If necessary you could utilize this to create some uniformity in your daily duties, reminders, etc.

 

So Let’s see this tag team with Start-Sleep!

tagteam timespan

I included the variable to display how this works so well. you just define when you want the script to stop that same day. It will show an error if you did it differently.  However, as long as the values are a positive number and not a negative integer you have a timespan.

The last example is using it to control things in the future….essentially a PowerShell Time machine, please share any of your experiences in the comments or on Twitter.

timemachine

so just know that time only flows in one direction. Trying to relive the past can cause you errors lol. Kind of ironic how that works outside the shell too. Don’t forget to visit other parts of the city. See ya around, and avoid cyclic redundancy errors!

Published by Xajuan Smith

Computer Information Specialist, with a desire to make the masses feel what I was born to channel...The emotion that strives us to do more, speak more boldly and with most sincere ideals that will make life easier and will not hinder the dreams we all have at any given time.

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: