SCOM 2012 Hello World !

I’ve been investigating how to connect to SCOM 2012 through code in order to extract information, and I thought a good first task (therefore a SCOM 2012 Hello World if you will ;)) would be to retrieve the current alerts. I couldn’t find any examples on how to do this, so¬†after some searching came up with the following.

I have used some sample code from Stackoverflow to read in the password for the user and have attributed the code with the source URL below.