Why I Love Overtime

It’s always easy to see things like having to work extra hours due to projects as a negative thing and in my past, I’ve certainly done so. I have managed to find a cure for this however by taking a leaf out of some of my friends books and spending the overtime payment on a cheap short break instead of some gadget.
Due to overtime payments, I’ve managed to get two 4 day, off season holidays at Centre Parcs to look forward to. Woohoo! :)

If our break at the Longleat one in January is anything to go by, Her Majesty and me are in for a treat. Gotta love those tropical domes when it’s cold and rainy outside.

Test Shots With an Old Kit Lens

I’ve been having a play with my camera today. Initially, the plan was to do some test shots with an old 50mm kit lens I had on one of my old K1000s in an old gadget bag. By the end of it, I was just playing about.

The subject is a bouquet of flowers I picked up for Her Majesty, don’t worry, no money was spent on the shoot at all!! :)

Can I also point out that other than resizing (which has done some pretty interesting stuff to the photos), I haven’t done any post processing.

Stress Can Be an Ally

I’m not sure I’m completely open to the ideas in this talk but I understand where she’s coming from, stress can be an ally. One of the simplest observations I can make of the people I consider most dear and the attribute I consider most important is an ability to focus when under stress. Some focus, some fold.

Querying AD with Powershell – First Shakey Steps

As I’m sure you know, I tend to jump in to learning stuff by trying out real world examples. This accelerates the learning process as there’s a desired outcome but it does make my understanding of the foundations a bit ropey. Never mind, let’s dive right in! :D

In order to be able to query Active Directory with Powershell, we need to first load up the module that allows Powershell to understand what the heck you’re asking for. That’s the easy bit:

Import-Module ActiveDirectory

OK, so now we’ve got the ability to ask AD questions, let’s ask it for some basic info. Imagine my login is the truly imaginative USER1 in AD. To run a dead simple query, I could just type:

Get-ADUser user1

What that will do is bring up a very little list of selected fields Microsoft thought you might want. Bless ‘em, they’re trying to be as helpful as they can. If you want the whole truckload, you can ask it for them:

Get-ADUser user1 -properties *

That’s going to give you the usual suspects of AD users’ properties, so you now have your SID, cn, samaccountname, department, etc. being displayed. If you don’t want all of it and you don’t just want the few provided by the normal output of Get-ADUser then we need to start doing the cool stuff in Powershell. You can pipe one command’s output into the input of the next, stay with me here it’ll make sense. By using the “|” operator you are saying that you want the output of command A fed into command B. So… command A | command B will process command A (in our case a query on a single AD user returning all of the properties for it in to command B (which we’re about to make a Select statement).

Select isn’t implemented the same way as you see in SQL, it’s a soft of cousin but the principles are the same. Here we go:

Get-ADUser user1 -properties * | Select cn, samaccountname, department, homedirectory

This one’s now a lot more friendly to you as it’s pulling back only the bits you want.
OK, moving on from querying a single user what if you wanted to get the username of everyone in the Marketing department? Well, as long as you’re using the fields in AD correctly for your users, you can use the Filter command.

The filter command is the first time you’ll see the curly bracket in this little post but it sure as heck won’t be the last! Curly brackets are implemented in a very similar way to C and C++ if you’re familiar with those two powerhouses. Imagine them as the boundaries for your complex little bit of code. Again, it makes more sense if you just see it in action:

Get-ADUser -filter {department -eq “Marketing”} -properties * |┬áSelect cn

Not too impressive yet but try to remember the output of this can be used with the “|” character to output the list that you just output to the screen as the input for a command to set up a new security group for example. Now we’ve turned what could take a while for a Marketing department of say, 25 people into a short set of commands that take no time at all to achieve what you were looking to do. That’s the Power part of the name Powershell!

I’ll be back soon to add to the querying side but for now, enjoy your weekend and I’ll talk to you soon.

Just Made Me Chuckle

I don’t know why but this little vid always cracks me up. The parents are doing a great job of miming and the little ones in the back are completely oblivious. A lot of my friends who are parents could probably pull this off too as their is nothing like looking after kids if you want to learn entire movies’ soundtracks!

Once again, sorry! :D