Getting Started with powershell

When I first heard about PowerShell (an eternity ago), I basically ignored it. I thought – “My Batch files and VBScripts work just fine.”

However – as more and more Microsoft tools began to transition to utilizing PowerShell I took it upon myself to learn.

Now.. I can’t imaging going back to simple VBScript (.. I admit I still have some VB I still use.. because those scripts still work!)

So how does one get started learning PowerShell?

1. Pick a project: You need a project in order to focus your mind. If you just try to jump out and read commands – all that will do is familiarize you, and that’s essential tool, but it won’t get it cemented into your brain. So think of something simple you want to do. For our sample – lets do something simple:

  • Get all the people in an active directory group.

2. Type it up: In your mind, break down the steps of what you want to do in as many steps as you can think of – think like a computer, what does it need to do to get the info you want. For our example:

  • define a group name to a variable
  • query ad for the group
  • look up the members of the group
  • display the members

3. Documented Code: One of the nice thing about doing this is that it helps you formulate your thoughts on what needs to happen in small workable chunks. Another is that you can use your comments as the beginning of comments for your code. It’s always important to comment your code, because when others review it – it will help them follow along…. including when that other is yourself 6 months later trying to revise your own code! In powershell we use the # sign to document a comment

  • # define a group name to a variable
  • # query ad for the group
  • # look up the members of the group
  • # display the members

4. Replace ideas with Code: The next step is to replace the ideas – with actual powershell. Don’t hesitate to use your favorite search engine and look up how to do each component.

# define a group name to a variable
$MYGROUPNAME = "Test-Group"

# query ad for the group
$MYGROUPOBJECT = get-adgroup -Identity $MYGROUPNAME -Properties *

# look up the members of the group

# display the members

This is a simple script (and it could be a lot simpler – one line in fact), but as you learn – the principles of how to learn stay the same. Break it down into smaller components and take it one section at a time until you are familiar with coding in PowerShell!

“Stop and do it right the first time”

… so like any homeowner I’ve had to fix a toilet or two in my time.  When a task comes up at work – I am the guy who is always saying “stop and do it right the first time”… so of course I am also the guy who doesn’t take his own advice on household chores.

So back to my toilet.   The tank was constantly running.  It’s a 15 year old toilet so I knew right away that the parts in the tank with the “5 year warranty” probably needed replacing…   Call me “Powers of Deduction Man!” – my superpower is knowing the obvious.

So I run off to my local Home Depot and get a kit… do i get  complete kit? nah. I grab the kit with just the most common pieces.

An hour later i’ve replaced the parts, and while things are better – I have a slow leak from the top tank into the bowl (not the floor thankfully).  Which I attempt to patch.     Six months later… my leak is back.  And it quickly gets … worse.

So back to Home depot for the … other half of the kit.    So kids – the lesson here..

“Stop and do it right the first time”

… back online after 20 years.

Sometime back in the 90s a friend and I ran a blog on this address.  It was much more difficult back then  – you had to code the website locally and FTP it up.   The other guy, Matt, and I used this blog to talk about the best beer specials in town.  I mean… what else do a pair of college guys blog about?    We tried to collate the bars running sales and specials in one place – and we even managed to get 2-3 advertising sponsors.  You know – old school advertisements,  add their Image to your page with an <img> Tag and maybe they cut you a check eventually?  I don’t think we ever even covered the $15 tag – but it was fun and we learned where to drink cheap beer.   I was the tech guy, and Matt tried to locate specials.   Matt is long gone…

..but I kept this site for email all these years.

So here I am a dad and husband, and I don’t drink like in those days – so I will limit these posts to my other passions.   These days – 24/7 isn’t about beer sales – but rather, my life as a Dad, Husband, Son, Friend, Homeowner, and IT support guy..




So … Welcome back to Atlanta… 24/7