Powershell on the Way to Work–Part 6


Hello, back on the grid again.  literally.   It appears that “Somebody” decided that redirecting all the traffic down a one lane residential street was a good idea.  So I’m stuck for a bit.  We can talk.

Being that I have Time on my hands I think today we’ll talk about time in Powershell.   It IS far cooler than the old CMD.EXE prompt and far more Powerful.   Let’s try something simple.  I’ll introduce you to GET-DATE

GET-DATE

Yep, that was awe inspiringly boring.  I get the date.   But that’s not all it can do.    It can tell me what Day that was.

(GET-DATE).DayOfWeek

Or better yet, maybe I just want to know how many days into the Year we are.

(GET-DATE).DayOfYear

I could even with a wave of my hand do this and step into the Future

(GET-DATE).Adddays(24)

Pretty neat eh?  There’s even built in formats you can choose from like a Short Date or just the Time.

(GET-DATE).ToShortDateString()

(GET-DATE).ToShortTimeString()

I can even tell it to show me a date based upon Criteria I give it.

GET-DATE –Month 9 –Day 13 –Year 1999

(Ed….Hmmmm I see no “Space:1999” fans in the audience here.   Well THAT joke was lost. )  But as you can see, GET-DATE is incredibly powerful as I can even produce content from it.   In fact later on when we show you how easy it is to work with Dates and Times in Windows Powershell you’ll wonder why you never used it before.

Well traffic is cleared up, I’ll be going now.  Don’t forget anytime you need examples of what a Cmdlet can do in Windows Powershell just key in GET-HELP NameOfCmdlet –examples

GET-HELP GET-DATE –examples

Touch base soon!

DSC_0158 (640x425)_thumb

Sean Kearney
Twitter: @energizedtech
www.powershell.ca

Comments (1)

  1. Papy Normand says:

    Thanks for GET-DATE –Month 9 –Day 13 –Year 1999 , as i ignored it

Skip to main content