2013 Scripting Games: Advanced Event 4
Summary: Scripting Games Advanced Event 4: Dr. Scripto needs audit 20 random users from Active Directory.Microsoft Scripting Guy, Ed Wilson, is here. Once again it is time to reveal an event for the 2013 Scripting Games that are being hosted and run by www.powershell.org. Head on over to their website to submit your entry.
An Auditing Adventure
Dr. Scripto isn’t saying he dislikes auditors, but they do seem to show up at the most inconvenient times—and with the oddest requests. So he’s tossing this particular auditor request over to you. This auditor would like a report that shows 20 randomly selected (well, as random as you can get) users from Active Directory. For each user, the auditor wants to see their user name, their department and title, and the last time they logged on. You also need to show the date their password was last changed, and whether the account is disabled or locked out. So that’s seven pieces of information. You’re to put that information into an HTML-based report file, and the file must show the date and time that the report was generated. Please make sure that all of the dates are normal looking, human-readable dates and times. Auditors being like they are, the “20 randomly” selected number will probably change in the future, so you’d better build this as a reusable tool. Have a parameter that specifies the number of users to pull, and default it to 20. Also parameterize the output HTML file name. Oh, but if the specified file name doesn’t end in “.html” or “.htm,” reject it. Get Windows PowerShell to do as much of that validation as possible. Dr. Scripto has to review your code, and he doesn’t want to read a lot of manual validation script. A domain admin will always run the command (on behalf of the auditor), and the resulting HTML file will be manually emailed to the requesting auditor. 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. See you tomorrow. Until then, peace. Ed Wilson, Microsoft Scripting Guy