The 2011 Scripting Games Beginner Event 9: Use PowerShell to Create a File Name Based on a Date


2011 Scripting Games badge

Summary: Beginner Event 9 in 2011 Scripting Games uses Windows PowerShell to create a file with a name that is based on a date.

About this event



Date of Event

4/14/2011 12:01 AM

Due Date

4/21/2011 12:01 AM

Event scenario

You need to add the ability to create a log file to one of your scripts. You would like the file name to follow the year, month, and day pattern so that you can easily discover which log file represents which day. For the purposes of this event, it is only necessary to create a text file with the name made up of the year, month, and day. An example of such a file name is 20110414.log. An example of such a file in a folder is shown in the following image.

Design points

  • You can save the file anywhere you wish.
  • You do not have to use a .log file extension (you can use .txt or another extension if you wish).
  • Extra points for detecting a previously existing file with same name and prompting for a new file name to use.

2011 Scripting Games links

2011 Scripting Games: All Links on One Page

Submit your scripts on PoshCode

Support our Sponsors!

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at, 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




    Leave a comment