HOWTO: Microsoft Certification Exam Preparation Generator

If you’ve ever had to write a Microsoft certification exam, you know that the exam syllabus is available from a URL that looks like this:

https://www.microsoft.com/en-us/learning/exam-##-###.aspx

Where the ##-### is the specific exam you are writing.  You likely also know that  the way Microsoft presents this information is not ideal from a study guide perspective.  It’s broken into categories and from there is just a jumble of words including many, many “filler” words like “plan and configure” or “configure and troubleshoot”.

I am writing a new certification exam and I wanted a simple means to know what specific concepts to study and play with in my lab.  I realized that I should be able to write a PowerShell script that would download the HTML from the URL above, extract the exam syllabus text and then cut out all of the unnecessary words.  This would leave me with a clean “checklist” of keywords I need to Google and understand.

So I wrote that.

Read more

HOWTO: Build a Temperature Alert System using a Raspberry Pi

I recently had my furnace fail while I was away on business.  Fortunately there were no lasting consequences but it could have been a very bad day.  To try and minimize the risk of such issues in the future, I decided I wanted a temperature monitoring solution that would alert me if the temperature in the house dropped below a pre-defined threshold.  I looked at things like a Nest and the TempStick among others but all of them were hundreds of dollars and or relied on third party cloud services.  Before I invested in something like that, I wanted to see if I could build my own solution for cheaper and that was designed to meet my exact needs.  I recently received a Raspberry Pi from a friend and decided this would be a great use for such a project. 

Specifically I set out to have the following goals:

  • The Raspberry Pi would record the temperature from a dedicated external temperature sensor every 20 minutes and record that value into a SQL database along with the timestamp
  • The Raspberry Pi would host a webserver that would allow me to review the current and historical temperatures from anywhere using my mobile phone
  • The webpage would also include a generated graphical chart showing the historical temperatures so I can review for any odd behavior at a glance
  • The Raspberry PI would automatically email me if the temperature dropped below a defined threshold so I could make phone calls to take immediate action
  • The Raspberry PI would upload a file to my off-site website host during each scanning interval via FTP
  • A cron job would run on my off-site webhost that would look for that file and if that file was not updated for more than one hour would alert me that either a power or Internet failure occurred at my house

I’m happy to report I achieved all of the goals above and figured I’d should share how I did it below.  Keep in mind I am not a software developer and so this solution is the result of grabbing things from the Internet and cobbling them together and tweaking until it does what I want.   With that out of the way, let’s begin with what you need to create something like this for yourself.

Read more

HOWTO: Backup and View All Contents of an Android Device

This HOWTO is written primarily for my own future reference but hopefully it’ll help someone else too.

Let’s say you want to back up the entire contents of your Android device.  How do you do that?

1) Download the Android Debug Bridge (ADB) tool that comes with the Android SDK Platform Tools.  The link of which is available here: https://developer.android.com/studio/releases/platform-tools.html

2) You should end up with the ADB tool in the following location: c:\adb\adb.exe

3) On your mobile phone, go to Options / Developer Options / and enable USB Debugging

4) Connect your phone to your computer via a USB cable

5) Open a command prompt and type c:\adb\adb.exe backup -apk -shared -all -f c:/adb/backup.ab

6) On your phone, you’ll receive a prompt.  Enter your password and choose “Backup my Data”  You will be prompted to enter the decryption password.  Remember this password as you’ll need it to view the contents of the backup

7) Wait for this process to finish.  It will take a while depending on how much data you have on your device

Read more

HOWTO: Generate a Microsoft Exam Checklist

Are you studying for a Microsoft certification exam?  If so, then you are probably familiar with the “Skills Measured” website that describes what will be covered on your exam.  If not, it looks something like this:

70-347_raw

I’m currently studying for my 70-347 – Enabling Office 365 Services exam.  The skills measured list above is a great starting point to use to determine what to search for and study and experiment with in your lab.  However the layout of the website has never appealed to me.  I would much prefer the text in Excel where I can annotate and color code it.  Unfortunately you can’t just copy and paste the text from the website into Excel as the HTML formatting makes everything a mess.

Read more

HOWTO: Automate One-A-Day Photography

This will be a somewhat unusual HOWTO compared to those typically on this site.  In an effort to lose weight, I decided I wanted to take a photo of myself, once per day so I could track and further motivate the progress of regular exercise.  I then wanted to overlay the date each photo was taken as well as my weight on that day.  Finally, I wanted animate these daily photos into a GIF and upload it to my website so I can remind myself anywhere of my objective of losing weight.  The trick is I wanted to automate this entire process.  This meant I needed to find a solution for the following:

  1. Remotely control my camera to be able to take a picture and download it from an automated script
  2. Be able to programmatically crop the image from the camera to remove everything except the white background and myself
  3. Have a mechanism to be able to overlay text onto an existing image so I can add the current date any my weight data
  4. Obtain my latest weight from my Garmin Index scale via Garmin Connect and append it to the image
  5. Combine all of the previous images into an animated gif so I can watch my progress
  6. Automatically upload the animated gif to my website so I can view it anywhere

To complete this project, I decided to try and leverage my Canon S100 which I purchased as Canon’s top-end prosumer camera in 2012.  As I researched my options however, I discovered that Canon disabled any kind of remote control capabilities for this camera.  Fortunately I discovered that some very smart people created an alternative firmware for many popular Canon cameras including mine.  This firmware is called the CHDK or “Canon Hackers Developer Kit”.  This provides all sorts of additional features that are otherwise only available in Canon’s DSLR professional series cameras.  The one that I’m most interested in however is that the firmware provided the option to remote control my Canon S100.

Read more

HOWTO: Write Vietnamese on a computer

I have previously discussed how to use a Windows based computer to write in Japanese and Chinese.  The time has come to tackle the next of the Asian languages, Vietnamese.  As before, the same disclaimer applies.  The information below is what I was able to figure out based on information primary from Google and Wikipedia.  Some or perhaps even much of it may be incomplete but it does appear to at least be logically consistent.  At first I thought typing in Vietnamese would be considerably easier since the language at first blush appeared to use the Roman alphabet, just as English does.  Therefore, I expected it to be as simple as “Select the Vietnamese keyboard and start typing”.  As I started researching however, I found this was not the case at all.

There are a couple of important things to be aware of when trying to write Vietnamese on an English keyboard.  Let’s assume you’ve used the “Language” Control panel applet and added the “Vietnamese” language already.  Once installed, you press the “Preview” button to see what the keyboard looks like this:

image

The first thing that will probably jump out at you is that all of the numeric digits on the keyboard have been replaced with special characters along with the open and closed square brackets, dash and equals keys.  Why is that?  To understand this, we’ll have to look at how the Vietnamese alphabet is constructed.

Read more

HOWTO: Convert binary to human readable text

This is a quick fun little HOWTO.  The was an article on CollegeHumor today that looked like this:

image

01010100 01101000 01100101 00100000 01110010 01101111 01100010 01101111 01110100 01110011 00100000 01100001 01110010 01100101 00100000 01100001 01101101 01101111 01101110 01100111 00100000 01110101 01110011 00100000 01100001 01101110 01100100 00100000 01110111 01100101 00100000 01100001 01110010 01100101 00100000 01100001 01101100 01101100 00100000 01101001 01101110 00100000 01100100 01100001 01101110 01100111 01100101 01110010 00101110 00100000 01001000 01100101 01101100 01110000 00100000 01110101 01110011 00101100 00100000 01000111 01101111 01100100 00101110

I was of course curious what the message above actually said so I wondered how quickly I could figure that out with PowerShell.  The answer?  Pretty gosh darn quick.

((gc c:\temp\binary.txt) -split " " | % { [char]([convert]::ToInt32("$_",2)) }) -join ""

Read more

HOWTO: Real world use case for Convert-FromString

This HOWTO covers a real world example of how to use Convert-FromString which was introduced in PowerShell 5.  As a reminder, this is the powerful new cmdlet that allows you to parse any kind of text data and convert the resulting data into structured PowerShell objects by defining “templates” for how the data is laid out and what information you want to extract.

The largest mall in my city includes literally hundreds of stores. I needed to shop for a particular kind of thing and wanted to know what stores I might want to check out.  I started by visiting the website for the mall.  This ended up giving me output that looked like this:

image

It’s not bad certainly but I would like to apply some filters to the dataset.  Now in reality, I could have certainly figured out what I wanted from this website but I realized this would be a great opportunity to see if I could make the ConvertFrom-String and FlashExtract do something useful.  Could I make a PowerShell object out of this data?

The first thing I did was download the webpage in PowerShell using the Invoke-WebRequest cmdlet.  Powershell includes a “parseddata” object that tries to break down any webpage into its component parts and return the results as nested objects.  I looked at the output and discovered that all of the data I was interested in was stored in parseddata.documentElement.outertext.  This gave me the following results:

image

Read more

HOWTO: Convert Complex Text Data into PowerShell Objects

PowerShell 5.0 introduces a wonderful new cmdlet called ConvertFrom-String.  Don’t let the simple name deceive you though.  There is some exceptionally complex math running behind the scenes here to do some truly wonderful things.
In fact, the code that gets executed inside this function is based upon the "FlashExtract" project completed by Microsoft Research.  How much math? Well here is a portion of the algorithm that was published in their whitepaper.

image
Source: http://research.microsoft.com/en-us/um/people/sumitg/pubs/pldi14-flashextract.pdf

The idea here is to give us as administrators the ability to take some existing complex text data, intelligently analyze it and convert it into native PowerShell objects. 
Technically we can already do this today using regular expressions.  But coming up with the right combination of letters and characters to produce the intended results is no easy task.  At least until now.
The idea here is that instead of trying to micro manage exactly character-by-character how you want to extract the data to get to the content you want, you instead simply ‘tell’ PowerShell want you want.
Specifically, you pass the ConvertFrom-String function a marked up template of the data that indicates which data is important.

It’s hard to understand in writing but will make a lot more sense once you see it in action.  This is also when the "ah ha" moment comes and you realize the power this new cmdlet offers.

For our example, we’re going to take a look at the c:\windows\windowsupdate.log.  This is a plain text log file that contains several columns:

image

Read more

HOWTO: Monitor a webpage and alert on change

This is admittedly kind of a silly HOWTO but does contain a number of very useful concepts. I am eagerly awaiting the Lenovo Thinkpad P50 laptop.  The official webpage for this laptop went live today but for pricing it simply says “Coming Soon”. Rather than refresh the page constantly, I figured I’d let PowerShell do … Read more