The Surly Admin

Father, husband, IT Pro, cancer survivor

DFS Monitor and International DateTimes

So the Surly Admin readership is growing by leaps and bounds. That’s right, we’re up to 3 now! And Garth gets two prizes, one for being #3 and the second for finding a bug in the DFS Monitor with History. His prize, you might ask? Getting to help me fix the bug, how exciting is that? Read on to find out.

Continue reading

September 28, 2012 Posted by | PowerShell | , , | 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

Windows Profiles – Saving a copy and deleting

Another script request out of Spiceworks the other day.  This turned out to be a long discussion as the OP wasn’t too familiar with scripting and Powershell scripting in particular.  This can be a bit of a problem sometimes as I speak in using Powershellese that can be a bit difficult for some.  The OP wanted a script that would hit a computer, copy all profiles older then 60 days to a central server then delete the profiles.  This was another interesting use of WMI and taking advantage of Powershell looping and PSObjects.  Let’s see how we solve this problem.

Continue reading

September 17, 2012 Posted by | PowerShell | | Leave a comment

Scan a Folder For Changes

Another fun little project popped up at Spiceworks yesterday.  OP (Original Poster) was looking to create a vbScript that would scan a folder for new files.  The Folder was actually part of an FTP site he had setup and he wanted to be notified by email whenever something new was uploaded to it.  Here’s how I went after the script.

Continue reading

September 11, 2012 Posted by | PowerShell | , , , , , | 24 Comments

Of Mistakes and Modules

Recently I’ve been doing more with Powershell functions, and blissfully telling people to run the script and then the function is available to you.  This is great if you use a Powershell ISE, either the built in one or a third-party one like PowerGUI.  ISE’s will keep functions alive after you’ve run your script, which is a great feature while you’re testing a new script.  The shell, on the other hand, isn’t so forgiving.  Run it there and it loads into memory and as soon as the script finishes it promptly is DUMPED from memory.

Oops, sorry about that!

Continue reading

September 9, 2012 Posted by | General, PowerShell, Random Thoughts, Technical | , , | 1 Comment

Get Service Information for a List of Computers

Today was a great example of how something that should be really easy with a computer turns out to be hard. Even in Powershell this happens. Case in point: on Spiceworks today a guy named dhubbard posted a vbScript that got a bunch of information about Windows services. It could be run against multiple servers from a simple text file.

Continue reading

September 6, 2012 Posted by | PowerShell | , , , , | 5 Comments