MS SQL AlwaysOn – Is current node the Primary?

I’m not a DBA by any stretch of the imagination. I do, however, need to provide basic infrastructure support to a number of Microsoft SQL servers.

A number of our MSSQL 2012 servers have been configured to use AlwaysOn. This presents a challenge when developers/admins need to run maintenance scripts because you can only run these against the primary database if you need to modify.

Doesn’t sound like much of an issue, but what happens if you run the script against a secondary node? Well, it fails with an error. I’d rather have something a little cleaner than that, and so came up with the below T-SQL script that you can wrap around your maintenance script and fail cleanly.

Continue reading

Posted in Scripting, SQL | Leave a comment

Intel NUC power adapter issue?

I purchased an Intel NUC5i3RYK around 4 weeks ago from Austins in Perth, and decided to put it together this afternoon while home sick. No joy, wouldn’t power up. No lights coming on, and no error beeps (via headphone socket) when trying to start it up with memory removed.

The physical store I bought it from didn’t have any stock but one of their other stores did. Yay! Second store confirmed ‘no power’ was the issue and gave me a shrink-wrapped replacement with no hassles.

Get home and plug it in, same issue 🙁

Continue reading

Posted in General | Leave a comment

Remove IP from Exchange Relay Connectors

A simple script to compliment a previous post

Continue reading

Posted in Scripting | Leave a comment

Select menu item from a dynamic Powershell array

Whilst talking with a colleague, the topic of being able to create a selectable menu item from a dynamically generated array came up. This was in the context of having a script that would query a list of all mailbox databases within our Exchange 2013 environment and allow the end-user to select one of these databases to then perform work on it.

I’m sure a simpler example based on listing files in the current directory would have been easier, but oh well 🙂

Continue reading

Posted in Scripting | Leave a comment

Powershell script to alert when someone RDP’s to a server

I’ve had a few issues with contractors logging directly into server, rather than using remote management tools. This script requires a scheduled tasks with a number of event triggers depending on what you want to alert on. I’m not too fussed when they log off or disconnect, but I do care seeing when they login or reconnect.

Continue reading

Posted in Scripting | Leave a comment