Checking if a domain’s mail server is actually Gmail using Powershell

Firstly, run powershell as Administrator and execute
[powershell]Import-Module DnsClient[/powershell]

After that you can run the Resolve-DnsName cmdlet:
[powershell]
Resolve-DnsName reddit.com
[/powershell]

Which returns:
resolve-dnsname

You can specify which type of record you’re interested in:
[powershell]
Resolve-DnsName -type MX reddit.com
[/powershell]

resolve-dnsname-mx

So, take that logic and add a sprinkle of basic string functions to get:
[powershell]
(-join (Resolve-DnsName -Type MX –Name reddit.com -ea 0).NameExchange).ToLowerInvariant().Contains("google")
[/powershell]

Which returns True/False if any of the MX records contain “google”, which would mean the mail server is Gmail.

‘$(TargetPlatformVersion)’ > ‘X.X’ Error

Every now and then I’ll find that Visual Studio just blows up – seemingly without me having changed anything – throwing the error:

numeric comparison error

A numeric comparison was attempted on "$(TargetPlatformVersion)" that evaluates to "" instead of a number, in condition "'$(TargetPlatformVersion)' > '8.0'".

Where the number at the end changes every so often.

How to fix this? Annoyingly simple.

Repair Resharper and restart Visual Studio.
repair resharper

Hope that saves you a few hours..!

Sony Xperia Mini X10 Pro: Corrupt Card “Fix”

So my phone regularly corrupts anything added to the SD card, even with various brand cards; all larger than the stock 2GB. I’d bought a 32GB one and though maybe it couldn’t handle that size (apparently it can) so went down to 16GB; still photos are corrupting as are podcast downloads, dammit!

Some people said it is linked to the phone not supporting certain class SD cards, some say certain brand, some certain size.

Bizarre fix that worked for me? Connect and mount your phone to your PC or use an IO File Manager app on the phone itself; open the two configuration xml files in the root.

Are they corrupted? Delete them and reboot – new ones are created and the phone works again.

Doubt this is in any way a long term solution, but it stops me throwing it out the window.

No warranties, it works for me, YMMV, etc.

Batch file to create an IIS7 website

Really simple stuff which is helping me out when hosting multiple sites for development on one machine; you either pass in as parameters or specify as responses

  1. the directory name of your site – e.g. “D:\Dev\MySite1” would be “MySite1”
  2. the port number you want it on
  3. the site ID

and it’ll set up the site, migrate your config settings to II7 if necessary, start the new site and let you know the URL to access it.

@echo off
setlocal EnableDelayedExpansion

REM Get parameters from user if they're not specified
if [%1]==[] set /P directory="Enter name of directory/site: "
if [%2]==[] set /P port="Enter port number: "
if [%3]==[] set /P sitenum="Enter site number: "

REM Create site in IIS
%systemroot%\system32\inetsrv\appcmd add site /name:"%directory%" /id:%sitenum% /physicalPath:"D:\Dev\%directory%" /bindings:http/*:%port%:%computername%

REM Attempt to migrate config to IIS7 stylee
%SystemRoot%\system32\inetsrv\appcmd migrate config "%directory%/"

REM Start new site
%SystemRoot%\system32\inetsrv\appcmd start site "%directory%"

echo site "%directory%" now running at http://%computername%:%port%

REM interactive mode
if [%1]==[] (if [%2]==[] (if [%3]==[] (
    pause
    exit
)))

I will change this to pull the next available site ID and port number unless someone else can tell me how to do that.

And yes, this would be very easy in Powershell but I’ve not done that version either..!

Also, if you’d like to know how I managed to get Syntaxhighlighter to work nicely with batch/cmd/dos, leave a comment. There are *no* nice, simple, tutorials out there with common mistakes, so I could paste my steps in here if necessary.

WordPress (free) on an Amazon EC2 Micro Instance (free – for now)

This first post is about how it came to be. A bit philosophical, I know, but that’s the nature of tech sometimes..

This is a version of wordpress (free blog engine) installed in Amazon’s EC2 (Elastic Cloud Computing – or Elastic Computing Cloud – or something like that, starting with Elastic and then another two “C” words) (free). Which I think is both thrifty, and tekky geeky, and therefore pretty awesome.

Inspired by Jaimal’s post over on 2bit-coder and an email from Amazon about a free tier, I set about having a go.

The only things needed to change from Jaimal’s tutorial, are that the current free versions of the AWS Linux VM are not quite Fedora; although you do install using yum, you need to log in as “ec2-user” instead of “root”, you always have to whack a “sudo” in front of any command that needs any real privileges, and you can’t use “phpmyadmin” to set up your mysql instance for wordpress, so you have to go old skool and do it by hand.

Anyhoo. Introductions over, next up – more on random web-related tech to follow.

Semi-related references:

How to run WordPress on the NSLU2 (“hacked” router I own that I based some of the wordpress install and setup on)

Mercurial how-to (since I’ve also installed that on my EC2 instance and will follow up on that at some point)