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

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

  • Comments 11
  • Likes

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

Division

Beginner

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 scripter@microsoft.com, 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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • You mention an image above, but its not displaying.

  • "You can submit one script per eevent!"?

    yeah that´s what i tried, curently it doesn´t work to upload a script to event 8

  • delete my last comment i scripted event 9 and tried to upload to 8 because 9 isn´t in the list

  • Event 9 not showing up in the list.

  • I must be missing something here. Is the goal simply to write a script to create the above mentioned file? or is it supose to do something aswell as making ths file?

  • @BradC  nothing extra. Just create the file as described

  • @Andrew Morgan.  OOPS sorry about that, the image should be visible now. Thanks for letting me know.

  • are you still rating scripts for events 9 and 10?

    as it´s over a week now and nothing happened...

  • meant 5 days, not a week

  • @kloinerF

    Yes we are still grading submissions. We will in fact be grading submissions after the last script is submitted on Friday night at midnight (-7 GMT). Judges will be working frantically over the weekend catching up. The final leader board will be posted sometime on Monday. Many of the judges are at the PowerShell Deep Dive conference and have been unable to grade scripts because the conference has taken all their time (I am also here at the conference). All scripts will be graded at least twice. So if yours is submitted it will be graded.

  • thanks!