2012 Powershell Scripting Games
Bit of a belated post, but over the first two weeks of April I competed in the 2012 Scripting Games. Overall, it was a pretty fun little competition which provided a nice challenge and education in Powershell scripting from an impressive cast of judges. At the end of the judging I was reasonably happy with my results, achieving and average of 4 stars across the ten advanced events.
The events were quite varied and most had more than one way to achieve the result. With that in mind there was usually a right way and a...less right way. Unfortunately the sheer number of entries seemingly overwhelmed the judges a little, I would have like to see more comments on the scripts, but understandably time is short for the tiresome judges. The judges comments were invaluable, and I learned quite a bit.
A couple of things that I will keep in mind for next year:
1. Don't go on holiday during the scripting games! Limited time and resources were a bit of a challenge...
2. Be prepared with more than one VM - some events asked to query remote machines, or required specific hardware (e.g. laptop computer).
3. Consider doing both challenges. Although you can only compete in one stream (Beginner or advanced) there is often some overlap either within the same event, or with later events. Code re-use is something to be encouraged (but don't go overboard!)
I would highly suggest competing next year for anyone in an administration role in a Microsoft environment (or Cisco, or VMware), Powershell is not going away and is something you will need to know. (Don't tell the boss, but it can also make your work much easier or even do it for you!)
Powershell Screenshot
Just a quick post to announce the availability of another handy (at least I think so!) script/snippet, PowershellScreenshot.
I also have another post that I need to get around to writing about my latet project, a Twitter client for Powershell. One day maybe...
SCCM Health Status Script
A few weeks ago I was tasked with babyitting duties on an SCCM environment whilst the regular guy is away. After a few days of logging in and checking site statuses and backups, I decided that it was time to script the task. The challenge of the task being that SCCM 2007 is one of the few products that Microsoft has released lately that doesn't include Powershell integration.
Initially this meant that my script was fairly limited. I was able to check the backup status by hitting the backup directories for each site. If there was a folder named "<<sitecode>>Backup" or "C??Backup". From there I could check the size and gather file modification dates to get the date of the last backup. If the backup failed, there should be a log file in the root of the backup directory which may help diagnosing the cause.
The second part took a bit more digging. After finding out that SCCM reveals quite a bit of information using WMI, I grabbed a really handy Powershell WMI Explorer. Using this tool I was able to fumble my way through finding out the component status for each site server.
Finally, I wrapped all of this in my usual XML/XSL structure to provide customisable reports and the job was done. The result is a functional script, but missing a few "nice to have" features such as:
- Determine the SCCM Site code if not provided
This can be done easily enough if given the SCCM server, but I would like to automatically detect from AD. This information is published in AD in the System Management container and just need to work out how to determine the correct primary site - Determining the backup location for each site
Currently the script uses a hash table to locate each backup directory. There is a maintenance task defined with this location, but finding where this information is stored is proving elusive.
The script is far from perfect, but did the job for me. Hopefully it is useful for someone out there.
The script can be found here:SCCM Health Status
Powershell Profiles
Another well overdue blog post, I have been busy studying to update to VCP5 (which I successfully passed a few weeks ago now).
I'm starting to get into Powershell a bit more, and starting to spread my love for the language around the office. Not having Powershell installed on my workstation means that I have different settings and configurations dotted around on each Server 2008 R2 server I logged on to, and decided it was time to start syncing a Powershell profile accross each machine.
The resulting script can be found here.
At the moment it doesn't really do much, but allows me to update the profile once in my personal drive, and then next time I fire up Powershell it will update (or on the first time, install). Thought it might be useful to someone out there :)
iLO Checker Powershell
I was recently lumped with the task of verifying iLO ports across our fleet of HP servers. This involved several mind-numbingly tedious tasks, perfect for some Powershell love. The idea was pretty simple: take a list of servers, verify that they were still in production use, and then verify if iLO is working on them.
It started off with a simple ping command, pinging the server and then pinging the iLO interface. The problem I quickly came across was the fact that about a third of the iLO interfaces hadn't been registered in DNS, so would not resolve to an IP. So I added a bit more robust reporting around this rather than just failing with an exception being thrown.
Having added the hostnames in DNS, I found a lot of missing information in the IP management tool, which lead me to decide that I probably needed to consider that some IPs may have been reused unintentionally. I realised I should verify that what I'm pinging is actually an iLO interface. Luckily, there is an XML document available on the iLO website that will tell you what type of iLO it is. Checking this was a simple WebClient download.
And to finish it all of I gave it the usual XML/XSL treatment, to make reading the results a bit easier. Overall I think it came out quite handy. No doubt there are other tools to do the job, but a couple of hours worth of work saved several hours more, so it worked out anyway.
The end result can be found here.
Edit: Helps if you actually upload the file...