Wednesday, 8 December 2010

Send email using PowerShell

I like it when you come across something new and today’s nugget is the PowerShell cmdlet Send-MailMessage.  I’ve used mailing scripts with VBS in the past, for example when I wanted email notification when a script had finished but the beauty of the PowerShell method is that you can do it with a single line of code.  As a bare minimum all you need is something like:

image

Okay, so I did say that you only needed a single line of code but I used the back-tick (highlighted) just to make it more readable.

You can find the TechNet article on the Send-MailMessage cmdlet here.

Tuesday, 7 December 2010

Checking BADMIFS

Recently there has been a slight increase in the number of files appearing the BADMIFS folder on one of our SCCM servers.  Given that these files get assigned a seemingly random name the only way to identify which client machine they’ve come from to identify any pattern is to open each one.  If you’ve only got a couple of BADMIFs then this task isn’t too onerous but anymore than that you need to look to automate the checks.  What I came up with was a…wait, can you guess?…PowerShell script that checks if there are any BADMIFS on either server and if found then extracts the particular line that contains the computer name and outputs it all to a text file.  A sanitised version of the code I came up with is below:

image