The 2011 Scripting Games Beginner Event 7: Easily Determine Days Between Dates by Using PowerShell
Summary: Beginner Event 7 uses Windows PowerShell to determine the number of days between dates.
About this event
Date of Event
4/12/2011 12:01 AM
4/19/2011 12:01 AM
Your company’s fiscal year ends on July 31. Recently, they implemented a “use it or lose it” budgetary policy in which budget money is not carried over from one quarter to the next. In addition, you have been told that if your department does not spend its entire budget request this year, next year’s budget will be reduced. You do not want to waste money; however, you do want to provide a reminder to people in your department as to the number of days remaining in the fiscal year. Your boss has tasked you to provide a single line of code for the departmental logon script that will display the exact number of days until the end of the fiscal year. Your company, of course, uses Windows PowerShell for the logon script. The output should appear something like the following.
There are 139 days until the end of the fiscal year.
- Extra points for using “native” Windows PowerShell cmdlets
- Extra points for using Windows PowerShell simplicity of code
- Extra points for reusable code that exposes parameters to customize the message string and date
2011 Scripting Games links
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.
Ed Wilson, Microsoft Scripting Guy