Scripting Wife’s Suggestions for Beginner Event 4
Summary: The Scripting Wife offers her suggestions for completing the PowerShell Scripting Games Beginner Event 4.
I want to get this done now. I am meeting some friends for breakfast, and I do not know when I will be back. Sometimes, at least with some friends, it takes nearly all day to have breakfast. Not that we eat all the time, but we go shopping afterwards. Being in the middle of the Scripting Games, I do not think we will go shopping all day, but then that is the great thing about having a week for an event—it lets me take a day off if I want to do so.
One thing I will say is that I like this year’s events better than last year’s. It is still hard, but I do not have to write a 100-line script (not that I ever did write a 100-line script…just saying). This event is no exception. My answer was a one-line script. That is right, I was able to do this in one line of code. And I actually thought this event was pretty easy. Here are my specific comments.
1. There is a cmdlet that specializes in comparing two different things. Use the Get-Command cmdlet and find that cmdlet. Next use Get-Help to show you how to use that cmdlet. Here is my super secret trick: When you use the Get-Help cmdlet, use the –Online parameter. It will open up the latest Help from the TechNet site. This includes all the latest changes and fixes. The Help on the computer only gets updated with Service Packs, so it is not as up-to-date as the Help on the web.
2. We only need to compare file names. This means that you need to get a directory listing. Because the folders are not nested, you do not need to make your cmdlet that gets directory listings do a recursive search.
3. My one-line solution was pretty simple, so I meet the not very complex requirement. I also used native Windows PowerShell cmdlets. I hope I get five stars for my entry, because I do not know anything I missed. But you never can really tell.
Good luck to you. I need to run, so I will talk to you tomorrow. I hope you are enjoying the Scripting Games as much as I am.