An (almost!) Dynamic DNS Script in Powershell

So in the last few months I have been learning a lot (a lot!) and I want to share my knowledge. One thing I whipped up on my way home from work was a small script to email me if my local IP address changed.

Personally, I own a .com which I have a subdomain A record to my home IP address, and I use this to keep that A record relevant. You could also manually enter your IP address and have it notify you if it changes, if you didn’t want to use a domain.

$users = "you@email.com" 
$fromemail = "thiscanbe@anything.com" # Email which the alert will come from
$server = "mail.yourserver.com" # SMTP server - you may need to include username/password, but my ISP (Optus) provides a free open one for subscribers

#Domain to check for discrepancies
$domain = "myipdomain.com"

#Your current IP address provided by IPify API
$ip = Invoke-RestMethod -Uri 'https://api.ipify.org?format=json' 
$ip = $ip.ip

#The IP address of your domain. You could skip this and just assign your current IP as a sting to check for differences
$dns = [System.Net.Dns]::GetHostAddresses($domain)[0].IPAddressToString

#What the email will contain. Feel free to modify this.
$HTMLmessage = @"

<h1>Alert Alert</h1>

Your Public IP address may have changed!
The IP address detected by this script is: <b>$ip</b>
<em>BUT</em> the IP address detected on your domain is: <b>$dns</b>

Please rectify the issue. This is an automated email and will continue to run until stopped manually or domain updated.

Warm Regards,
The robot in your server "@

#The check if your IP doesn't match the domain IP, and it's not blank
if ($ip -ne $dns -and $ip -ne "") {
#Send the email
send-mailmessage -from $fromemail -to $users -subject "Public IP Address Change!" -BodyAsHTML -body $HTMLmessage -priority Normal -smtpServer $server 
}

And it’s as simple as that. I have the script run every 10 minutes or so using Windows Task Scheduler. If you IP does change, be aware it will keep sending the emails every 10 minutes till you either fix the domain, or disable the script.

While I was researching this I did come across the face that Hover (my personal domain registrar) has an unofficial API that you would be able to use to automatically update your A record. This would mean the script could be completely automated, and work as well as the DynDNS settings in your router.

I hope you find this helpful! If you have any questions, ask in the comments ūüôā

-Andrew

The Great Migration

Today marks the end of the great migration from my old web host to my new one. My old host Arvixe has put one step too many out of place. A colleague of mine mentioned they were acquired by a conglomerate known as EIG Hosting and ever since their support has been abysmal. Not to mention they stopped providing free domain privacy without telling me. Very poor. I have since moved to A2 Hosting and am fairly happy with them so far. During the upgrade I also updated my homepage with Bootstrap.

Work has been good. I have been learning a lot about ServiceNow as I continue to administer the system. Go-live is only 8 business days away and things are getting pretty fast-paced. In among the work I have applied for a new position a few steps up the ladder, and will be interviewing in a week or so. If all goes well I may be in charge of people soon!

Another project is on the go, however I don’t want to jinx it. It’s hard to find time between home and work, and motivation can be lacking after an already stressful day.

No Man’s Sky came and went. It was what they said it was going to be, and what I expected it to be, but it certainly fell short of what a lot of people wanted. I put probably 40 hours into it, and while I didn’t get to the centre of the galaxy, I definitely have done most stuff. I’ll go back to it when they have patched in a bit more content.

Thanks for listening!

Home Again

So it turns out WordPress converts html code to characters. Guess the joke in my last post didn’t work. Oh well, live and learn.

We returned from our holiday a week or two ago and have since got back to work. As I half expected I didn’t get time to write or learn while we were overseas, I had far more important¬†things to do. It was a holiday after all!

On the work front things are changing. My position has been moved from the Service Desk to the “Administration” team within the service centre, basically meaning I am one of the primary administrators of our ITSM tool. It has been pretty interesting in the day or two where I have actually been able to “administer” the system, but the transition project is at a point where we can’t do too much to the system, so I am helping out some other areas currently.

Part of this new role is writing Javascript, and the system is built on AngularJS, both of which are courses I could take at Codecademy. So that is something that I have put on my to-do list when I get a chance. This is all being hampered by the new podcasts I have gotten in to (The Black Tapes, Within the Wires) and new games which will be coming out (No Man’s Sky). Holy crap I am keen for No Man’s Sky.

While I was away I had an idea for an app reinforced, but I am struggling to find time to learn how I would be able to go about starting to create it. By the time I get home from work I’m basically spent, and on the weekends I will spend them with my Patrice or relaxing. I’m considering trying to save time at work and take a whole week off, and use that week for productive things, but I know if I did that I wouldn’t actually get anything done. It’s a tough circle.

Once again I’m going to say how I would like to keep the blog more updated. I’m really hoping that getting a laptop I can take to and from work will help out with that, and, well, I am writing now aren’t I? Maybe I’ll make a habit of it. Fingers crossed!

< Two Days!

For those of you who don’t recognise ridiculous unicode references in HTML, that stands for Less Than.

We leave in 44 hours or so, and it’s very exciting. We have got some Euros and some GB Pounds (as we discovered there are other types of pounds, such as Gibraltar Pounds), and have pretty much packed our bags. The animals have been around a fair bit and they have been very sooky, almost like they know what’s going on. We are definitely going to miss them.

The air-ships we are getting the whole way are Boeing A-380’s, which come with in-flight wifi ($1 for 500mb) and power outlets to every seat, which means I should be able to at least write a bit, if not try continue to learn Javascript on the way over. I might even redesign my website (ha. I say that all the time).

Now all that’s left is to actually¬†go.

I’m Back (Like Baby Got)

I am posting again on my blog. It has been a long time and reading some of my old stuff made me cringe. It is funny, however, that at the end of the second-last post about OSX I mention not getting a new laptop, and that’s exactly what I have done. Oh well. (Thank you Patrice <3)

Lots has changed since last update, most of which I don’t particularly want to write about. Coming up however (9 days, 23 hours, 33 minutes, 42..41.. seconds) Patrice and I are embarking on a trip to Europe, and I would like to chronicle some of that here, in everlasting digitalness. I can’t promise photos, or that anyone other than us will read it, but hey, blog maybe?

Other things I’m currently doing: Learning ServiceNow (ITSM/Cloud tool) which I am now a certified system administrator, Trying to learn Javascript, dealing with our new cat Pumpkin, Taking pictures with our new(ish) camera, and coming up with great ideas what I have not fleshed out at all but are totally a great idea. Virtual Reality is also pretty fresh right now, with Oculus and Vive launching. I wouldn’t mind getting one but they are not cheap. Maybe next generation?

Work hasn’t changed much, but it may in the future. With my ServiceNow admin credentials I’m looking to transition away from the Service Desk to the Service Management Project / maintenance of the application / development of new modules perhaps, so that will be interesting.

That’s all for now.

Caio!

 

Here we NaNo again…

Yeah, so I have decided to¬†give NaNoWriMo another shot this year. There are a few things working in my favor, like the fact I have 15 of the 30 days of the month off of work.¬†I also have a bit more of a plan I threw together a few days ago, and I’m going to be writing a completely different genre. SCI FI! Other than that, I’m still a bit anxious about the whole thing. There is no reason to be of course, it’s not important, it’s not mandatory, it’s just for fun. But I still feel responsible. Oh well, we will see.

What else has been going on since I last voided my conscience into the nether? OSX 10.10 Yosemite is alright I guess. Not a whole lot changed from Mavericks for me as I don’t have an iPhone or use the default Mail, iTunes or browser. I’ve upgraded my PC a little (a lot) and it’s awesome. Got some new speakers I’m in the process of breaking in (Microlab 5C’s), and I have been watching a lot of King of the Hill.

I’m sure that there will be more posts here within November as I will be trying my hardest to procrastinate, as I always do. Stay tuned!

My thoughts on OSX

So here I am, typing this post on a bloody Macbook Pro 13″. Who would have thunk it? My Brother-in-law bought a new Retina one and I bought his current one off him. It’s a machine I know pretty well, as I helped him upgrade the RAM and put a hybrid HDD in it a while ago now. My experience hasn’t been bad so far. I have to say that it’s been kinda fun having a new set of problems to overcome to get it set up how I like it, and my experience with Linux has been fairly helpful.

When I first got it I had to completely reinstall the operating system from scratch because it wouldn’t let me just reinstall 10.9, as I didn’t have an Apple ID with that assosciated with it. I had to go back to the version that came with the device (10.6) and then update to 10.6.8, finally getting to the “App Store” and purchasing the free upgrade to Mavericks, then waiting the number of hours while it did it’s reinstall. The beginning was a little messy, but since then everything has gone fairly smoothly. I installed all my standard applications, such as Chrome, Google Drive, Steam, Battle.Net and KeePass (which might warrant an entire blog post to itself, it’s so cool) and am really starting to get it set up how I am finding I like it.

The best advice I can give anyone looking to move from another OS to OSX is simply, Command+Spacebar. This keyboard shortcut opens a “Spotlight” search which can be used to find applications, documents, settings, everything. It’s like hitting the Windows key in Windows 7 or later, but it’s actually a bit better than that, as it gives you some context on the results such as which application or folder they are found in. Secondly, get to know the gestures. I love¬†using full-screen apps, and with a three-fingered-swipe, I can switch between them. It’s¬†almost as easy as alt-tab (or Command+Tab).

Something that OSX does really well is backups, and if you can use the Time Machine to get network backups running, it’ll keep hourly, daily and weekly backups for a long time, all incremental which you can jump back to at any stage. This took a little bit of doing (read: forcing with a large, digital hammer) as I have a Windows Server which I wanted to back up to. Normally Time Machine only backs up to a portable hard drive, or an apple-based NAS. I followed a guide online which allows you to use Terminal command lines to create a dummy-disk, format it, move it to a network location then mount it so that Time Machine doesn’t know any better. There’s nothing quite like pulling the wool over a computer’s eyes!

Another really, really cool thing which the Macbook lets me do is Steam In-Home Streaming. Because I now have two computers on the same network with Steam installed, it allows you to run you game collection on one device (my desktop, with the better hardware) and “stream” the resultant output to my Macbook, which controls the user input. It’s pretty crazy! It means I can play all the latest games I have bought on the laptop without running it hot, or having to turn the graphics down to Low.

I’m pretty excited about this. Hopefully I don’t decide I need a better one anytime soon!

End of Year

It’s getting awfully close to the end of 2013, and heading into the (crazy) year 2014. It all sounds so futuristic. After reading one of my friend’s year-in-review blogs I thought it couldn’t hurt to do one of my own, and vent a little.

So first up, some serious bitching.

I’m pretty sick of work. I find that I’m a guy who is happy to do a menial job for an extended period of time, as long as the conditions are OK and I’m working with people I get along with. I have been in my position on the Service Desk for a number of years now (3 1/2 or so?) and have not really had much of a problem with it until the last six months. Sure, the work is fairly boring and repeditive, but at least it was a fairly cushy job. After most of the department was fired by the Liberal government our workload dropped a good 60%. This meant that we always had time to take a breather between calls, and could have a bit of a talk amongst ourselves. It also meant that I got to know the people I was working with fairly well, and the work environment was fairly good. I’m not exactly sure what happened, but our “manager” was changed, and the new one slowly started to get more and more tyrannical. About three months ago our Director also changed. At first, I thought this was a good thing. It would fix all the sexism and nepitism of the previous one, however I was wrong. The first team meeting we had after the change, the new director introduces herself and brings in a “List” of things the Service Desk need to improve in their work in order to qualify for a “up to 4 week secondment” to another team within Technical Operations. Basically, it’s just another way of getting everyone to work harder with no pay-off. The only person so far to have benefited from “The List” is the one person on the Service Desk who brown-noses to the manager. Great system.

I was told to my face that I would not be able to apply for any positions within the government as my manager couldn’t give me a good reference because my “attitude is poor”, and our Director has yelled at the whole Service Desk and lied to our faces about who is actually on “The List”. It’s all shambles. I’m so jaded about the whole system that the only way I can see myself enjoying this place again is if my Manager and Director change. You wouldn’t think that it would be hard to respect your employees, but no, we get treated like children.

I’d like to say that it is out of my system now, but I’m still fuming. Anyway. On with the better part of this post.

Firstly the biggest change recently has been Patrice getting an offer of a full-time position as an RN. While she hasn’t got a start-date yet, it is coming. What that means for us is a little more stability in income, and we might actually be able to get some big things done around the house. I’d also like to take some time off for myself. We always discussed taking time off when Patrice got a full-time job. I’m not sure if I want to take a block of 4 weeks at half-time or if I should maybe break it up into mon-tues-wed off for 7 weeks. That would be excellent.

If I do end up taking a big whack of time off work I would like to set myself some goals to achieve while I was away. I think all through 2013 I have felt a bit let down with the opportunities I have passed up. There was the programming course I tried to do online, which I completed about 60% off then gave up. There was also NaNo which I got to 30% or so of the final goal, and various other little things. It’s so hard to dedicate myself to something like that when I’m working full time, and spend most of the weekends doing things with family (I really do enjoy those things though).

Well anyway, here is a list of things I would like to do throughout 2014 in no particular order:

  • I want to program more
  • I want to set up my Raspberry Pi (with camera)
  • I want to¬†finish¬†a project I start
  • I want to save some money for end-of-days-esq situations
  • I want to recreate my website and be happy with it
  • I want to make more of an effort around the house

I’m sure I’ll think of more. I might update with a final list as they come to me.

That’s all for now. It’s good to get this off my chest.

na-NO-wrimo

The 30th of November came and went, and unfortunately I did not make my target of 50,000 words. I started fairly strong and managed to get to about 15,000 in the first week-and-a-bit, but then real life caught up, and I found I didn’t have the time or the inclination to push myself to write every day. I am very happy with what I did manage to write, and as I saw someone on twitter say the other day “Words that were not there in October are now there in December”. Patrice wanted me to keep writing, and I will try, but I think it’s going to be very hard to find the time.

There are so many little projects going around my head at the moment that I wish I had about a month off, and enough money to chase them down and get them off my damned to-do list. I have a Raspberry Pi that I really want to set up as a time-lapse machine, maybe with some additional functionality that I am yet to decide on. I have a Mini-ITX motherboard I want to build into a tiny server with my first home-brew case. I really want to make my homepage a little more exciting. We need to do a fair bit of work to the house, and go to the dentist. Stuff really piles up.

One thing that I have been doing pretty well is the “water challenge”. A friend of mine at work has said we should only drink water (for health reasons) for as long as we can. It’s been 6 days so far, and I think I might have lost about 3KG’s. We want to keep it going until at least the 17th of December, so I can only hope I lose a little more weight between now and then.

So much do to. So little time.

The NaNo Countdown

November the 1st is tomorrow, and my enthusiasm for the task ahead is… shall we say “changed”? I don’t really know what happened, but for the last couple of days I have been very warn out (lack of sleep) and I just haven’t been looking forward to it like I had before the weekend.

It may have something to do with the “Weekly Drinks” I attended last Thursday with other NaNo hopefuls. It was an interesting experience which I mostly enjoyed, but it had some downsides. When I arrived I was introduced to a few people (gee I’m terrible with names), and had about ten minutes of chatting before we had to move from a round table, to a longer thin table. This was complimented with a crazy extrovert who stole the conversation and essentially forced myself and two others into a 4-person conversation with him for the rest of the night. It just wasn’t as awesome as I had hoped it would be.

For the last few nights I have been trying to go to bed early to beat the previously-discussed “tired” issue, but it doesn’t seem to have been working. I have had 8 hours of sleep or more for the last two nights, and I’m still feeling like crap by midday. I guess this hasn’t really been helping with the optimism for the task ahead. I might try getting to bed even earlier tonight (maybe 9pm?) get in early to work and do a little writing before-hand.

The 2000 words a day push is going to be hard for me to hit during the week, with so much stuff I usually have on weeknights, and not being 100% sure of my plot. I am 95% sure I’m going to attend a bunch of write-ins over the month, and really push myself to do a lot of work on those days. If I can do 5 or 6 thousand words a write-in, that would probably get me half way to the finish in about 4 or 5 days throughout the month. the rest will have to be hit and miss during the week.

Patrice has been really pushing for me to do it. She wants really wants me to enjoy what I do for a living, and realises that what I’m doing professionally at the moment is not my ideal long-term occupation. I’m really glad she is, but I don’t know if writing is what I want to do long-term either. That, and I don’t know what sort of outcome I’m going to get from NaNo. There seems to be a lot of people saying that a “Draft 0” is all you get, then you have as much work again to get it to a readable, editable level. I know it’s all about word-count during November, but does that mean I am going to have to let quality slide? Can I even write quality in the first place?

What else have I been doing recently? Pokemon X and Y came out on the 3DS, and I have been playing through Y. It’s a great game, but quite frustrating at times. The japanese grind has always kinda got me down. I just want to progress but I’m stuck in a cave getting attacked by bats every 20 seconds, and I don’t even know if I have to be there. At least it’s a distraction from worrying about NaNo…