Month: May 2012

Run Powershell from a Network share – A Cheeky Bypass

There is a backstory for this which will be saved for a later post, but this is too good to not share.

So, say for example you have a script which isn’t signed (Ahem!) and you’re wanting to run it from a UNC path (Network Share)

If you try and do this, it’ll throw up a security error.

But to bypass this, you simply have to call it from a batch file something similar to this

This will then bypass any issues you have, and it’s for a one time use so you don’t have to change the ExecutionPolicy within Powershell.

Hope this helps some guys out there trying to run certain scripts on Logon (Or scheduled tasks!)

Icinga – Scalable and Manageable configuration

So, over the past days, I’ve overcome quite a few hurdles in getting Icinga up and running, configured with windows hosts and such.

As part of the process, I’ve rolled back the VM time and time again just to understand exactly what is going on with it all and not blindly following a guide.

I’m now at a point where I’m happy and deciding how to complete the rest of the setup and deployment.

Now, if you’ve ever set up Nagios or Icinga, you’ll know the configuration files can be quite messy to a novice (And some of the vets at times I imagine!)

So, whilst I may know the system… it’d make no logical sense to anyone else I work with, or if I were to be struck by lightning, my less-cool replacement.

To counter this, I gave some thought of how to arrange stuff within’ Icinga, after some google-fu I came across a post by Matt Simmons which really hit the nail on the head as far as I’m concerned see;

So this is the result, and by far no means finalized work in progress for how our Icinga directory will end up looking;

  • Hostgroups
    • App-Servers
    • SQL-Servers
    • Windows-Servers
    • HAProxy-Servers
    • Linux-Servers
    • VMWareHosts
  • Objects
    • Commands
    • Computers
      • Windows
      • Linux
    • Network
      • Firewall
      • Switches
      • Routers
      • VPN Links
    • ESX Hosts
    • Misc
  • Services
    • WindowsServices
    • LinuxServices
    • VMWareServices
    • SQLServices
    • HAProxyServices
    • AppServices
    • DefaultServices
  • Templates
  • Modules
  • Stylesheets

These are a little generic names, they’ll be altered for our environment to match as much structure as possible that we have elsewhere e.g. Windows Security groups, AV groups, folders on our VMWare Datacenter etc.

But, by abusing hostgroups… it should be possible to “configure” a machine by simply creating its own host file (w00t!)

I’ll also be looking to streamline some of the following post into our config as well;

Once this is done and dusted, everything is populated… The next task will be trying to automate the addition of hosts~!

How to rename your Ubuntu 12.04 Server

So, you just screwed up the name of your Ubuntu server?

Well that can be changed in no time and with no downtime

Just follow the ermm following;

  • Set a new hostname
sudo hostname
  • Edit the /etc/hosts file

sudo vi /etc/hosts

  • Edit the /etc/hostname file

sudo vi/etc/hostname

In some circumstances, you may also have to change the /etc/resolv.conf file.

Simple, yes! But worth 90 seconds to write out ;P

Windows Perfmon Counters, which one matter and why

Windows Perfmon Counters, which one matter and why

How to Send an e-Mail from Powershell

Thought I’d slam this up here considering I’ve written the little snippet for this (I say wrote, it’s no doubt in many places on the net)

This little bit of code has a lot of potential, it can be used to automate report sending, notifications, outputs of queries etc!

In time I’ll post some examples of how to use it, but if you’re just looking for a clear-cut way of how to fire an e-mail off, then here it is

This script utilizes the inbuilt Send-MailMessage cmdlet built int PowerShell V2.0, more information can be found at the following

Migrating All My Scripts to Gist @ Github

I actually noticed today that the formatting is totally screwed on any of the scripts, or snippets of code I’ve posted.

So what I’ll be doing from now on is uploading all code snippets to Github’s Gist so in the future if any lost Sysadmin stumbles across this page then you’ll have an easier time modifying and reading the code thanks to the inbuilt syntax highlighting 😀

You’ll be able to view all these code snippets over at