The Surly Admin

Father, husband, IT Pro, cancer survivor

Exporting User Information

Need to export user information to a CSV?  Perhaps as part of your termination user process?  Incredibly easy with PowerShell, let’s see how to do it.

Continue reading

Advertisements

July 14, 2014 Posted by | Powershell - Getting Started | , , , , | Leave a comment

Additional Thoughts on Hashtables

I recently starting looking at the subreddit for PowerShell, and I’ve seen a lot of people using hashtables for just about everything.  I’ve even seen a few people using them over at PowerShell.com and in both cases the usage was dubious at best.  Here are my thoughts on it, and why hashtables are usually not the right choice.

Continue reading

April 8, 2014 Posted by | Powershell - Getting Started | , | 6 Comments

Simple Multiplication Table

My daughter has really been working on her multiplication tables this year and normally she comes home with a study sheet for each number, all the way up to 12.  This week we’re working on 8’s, so 8×0, 8×1, all the way up to 8×12.  Unfortunately she didn’t get a worksheet so she decided to make her own.  If I can take a moment of fatherly pride, she does this kind of thing all the time without us making her.  What a gal!  Well, one of the ways I motivate her is to race her.  So it was on.  Can I write a PowerShell script and get the multiplication table out before she could write it out?!

Continue reading

April 4, 2014 Posted by | Powershell - Getting Started | , , , , | Leave a comment

Powershell – Steep Learning Curve?

This has come up at Spiceworks a couple of times, the which should I learn discussion. vbScript or Powershell? Considering the theme of this blog I don’t think you need to ask which camp I stand in. But what about this steep learning curve? Here are my thoughts.

Continue reading

March 28, 2013 Posted by | Powershell - Getting Started | , , | 9 Comments

Powershell Best Practices – Surly Style

I have to be honest, I’m a bit of a perfectionist.  I like things neat and tidy, and I have to be honest, I see a lot of Powershell code being posted on the Intrawebs that drives me crazy.  I’ve kept my peace, my mouth has been shut and I let things slide. I have.  I haven’t said, wtf are you thinking?  How the hell is anyone supposed to know what this is doing?  I sure as hell ain’t gonna run it to see what happens!  But no more.  Time to put down here a couple of things I do in Powershell to try to make my code a little easier to access for the average admin.  Clearly you should be doing it too.  Surly Style.

Continue reading

December 31, 2012 Posted by | Powershell - Best Practices, Powershell - Getting Started | , , , | 2 Comments

Powershell and the Pipeline

Continuing the “Getting Started” series with a talk about the 7 major things you’ll use in Powershell.  This is by no means a comprehensive list of how to use Powershell but something to get you started.  One of the more powerful features of Powershell is the pipeline.  If you ever used DOS and batch programming you know all about the pipeline and Microsoft has really embraced it with Powershell.

Continue reading

September 27, 2012 Posted by | Powershell - Getting Started | | 1 Comment

Get Started with Powershell: Loops and branches

I think I mentioned this before, but I’ll say it again now, the purpose of these little “Get Started” posts is not to teach you Powershell but instead is meant to give you the foundations for moving forward with your own scripting.  There are far better tutorials out there and I encourage you to seek them out if that’s what you need.  Here I just want to get you started.  From the past couple of days we’ve learned 4 key cmdlet’s and methods to help us discover Powershell by asking Powershell.  With this post I want to talk about the most common method of creating a loop and branching your code given a particular condition.

Continue reading

September 26, 2012 Posted by | Powershell - Getting Started | , , | 2 Comments

Powershell Discovery: Variables

This is true of any programming/scripting language.  Variables are the life blood of what you do.  Without them there is really nothing you can do in a scripting language.  I’m going to assume you know all about variables so I won’t get down to what they are.  But one of the fun things about variables is all the different things you can store in them.  Objects, datetimes, integers pretty much anything can be stored in them these days.  And Powershell has a truly dizzying array of variable types to work with.  Figuring out what you’re dealing with is key to a successful script.  There are a lot of things you can do to an object, but not all objects are created equal!  So some objects will allow you to Convert them to datetime, and others won’t.  How do you find out?

Continue reading

September 25, 2012 Posted by | Powershell - Getting Started | , , , , | 3 Comments

How do you start using Powershell?

I’ve been asked this a couple of times, and to be honest I’m not sure I’m the best person to even ask this question of!  Why? I’m very much a hands on learner, I often tell people that I have to learn with my fingers not with my brain.  What this means is I have to run a script and see how everything works to really understand something.  Reading from a book is all well and good, but it doesn’t “work” for me until I actually sit and try it.  That’s why in my office you won’t find many technical books–and the ones you do find I’ve almost never actually read!

Continue reading

September 24, 2012 Posted by | Powershell - Getting Started | , , | 1 Comment