The Surly Admin

Father, husband, IT Pro, cancer survivor

SpiceWorld 2014 Just Around The Corner

Getting very excited that SpiceWorld 2014 is just around the corner.  Heading out to Austin in a couple of weeks to enjoy the spicy goodness.  Rob Dunn and I are again putting on our Introduction To PowerShell presentation, and I think we’ve made some good tweaks to the presentation to improve on it from last year.  If you’re new to PowerShell and coming to SpiceWorld this year, you HAVE to come check us out.  Unless anything changes we’ll be up in Room 9 on the second floor.

SpiceWorld 2014


Introduction to PowerShell

Oh, did I mention that Jeffrey Snover will be there?  He’ll be talking about “Just In Time, Just Enough Admin” so should be a fantastic 1, 2 punch of PowerShell–and general best practices–goodness.
It’s been so busy at work, and the PowerShell scripts have been flowing fast and furious.  Unfortunately they’re so specific to the environment here that I haven’t been able to publish anything.  I did finally come across another way to produced WhoIs data, so my WhoIs script is back in business!  One nice thing about the report is I’m using a technique that converts HTML tables into XML and allows you to manipulate them directly.  This is good because there’s a current bug in Set-CellColor script that if two cells in a row have the same data, and you’re trying to color the cell with that data BOTH cells will get the color treatment.   Using XML looks very promising in stamping that out but I just haven’t had time to dig into it yet.

Wish I could show you all the cool things I’ve been able to work on!  I’ll have to write about some of them as I can generalize a lot of it–I think!

September 12, 2014 Posted by | General | Leave a comment

Getting Directory Information Fast

By now, you may have noticed I’m always on the lookout for better performing code.  This has turned out to be a good habit now that I’m working at athena health, as the pure scale of things is so much larger than places I’ve been at in the past.  One piece I’ve never been able to speed up, though, is iterating through folders and files.   Nicolas1847, a PowerShell scripter on Spiceworks, has come up with an ingenious method to get simple directory information using Robocopy (of all things), and a colleague at athena health likes to shell out to CMD.exe and use the old DIR command.  But are they faster?  And if so, which one?

Continue reading

August 4, 2014 Posted by | Powershell - Performance | , , , | Leave a comment

Quick Script: Date Ranges

Ever need to get an array of all the days between two dates?  This script will calculate the date range and load up an array with date/time objects for every date in between the entered times:

To use it, simply call the function

  • Get-DateRange
  • Get-DateRange -Start 7/24/14 -End 8/1/14
  • Get-DateRange -End 7/20/14

And just to pretty it up as a Function and with comment-based help:

July 25, 2014 Posted by | PowerShell | | Leave a comment

Spicecorp Thursday, July 24th 2014

Should have posted this a couple of weeks ago, but I’ll be at the Boston Spicecorps this evening doing a quick, one hour introduction to PowerShell.  It’s all about taking some of the fear away from using PowerShell.  We’ll be going over objects and the 3 commands you have to know to really get into PowerShell:

  • Get-Command
  • Get-Help
  • Get-Member

There’s about 10-15 minutes of slides to get through, then the rest of the time is all sitting in front of the ISE and writing a script from the inside out.  If you’re not doing anything this evening and you are in the Boston area, swing by and say hello!

Link to Spicecorp Boston

July 24, 2014 Posted by | General | Leave a comment

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

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

Extending the Active Directory Schema

Bit of a departure from my normal PowerShell-centric posts, I want to talk about extending the Active Directory schema.  There’s some really great information on the Internet for doing this, but there are some things to consider and none of that information seems to be in one place, and I wanted to bring it together here.

Continue reading

July 7, 2014 Posted by | Technical | , , , | Leave a comment

Getting Last Logon Information With PowerShell

Recently I had to write a report that got the last logon date for all of our users and I really ran into the LastLogonDate problem.  What problem is that, you might ask?  Well, it’s been documented a lot but the root of the problem is when a user logs into a domain account, their login time is recorded into the lastLogon field in Active Directory on the domain controller they authenticated against.  This field is stored as FileTime, which is the date and time as a 64-bit value in little-endian order representing the number of 100-nanosecond intervals elapsed since January 1, 1601 (UTC).  And just to make it a little bit more fun Active Directory does not replicate it.  So if someone logs in in India, and you query your Active Directory Domain Controller here in Massachusetts you will NOT get the updated information.  So now what?

Continue reading

June 30, 2014 Posted by | PowerShell | , , | 1 Comment

Monitoring the Progress of a PowerShell Job

Working in a big Enterprise is a whole different animal than small business (which has been my space for a long time).  I’m finding myself doing a lot more multi-threading because of the pure scale of things that need to be done and running a single threaded sequence just takes too long.  But that doesn’t mean I don’t want to give my users feedback about the progress of my scripts, in fact, the larger the work load the more important feedback becomes.  I recently discovered a technique that allows me to do just that–but not before putting my own spin on it.

Continue reading

June 23, 2014 Posted by | PowerShell | , , , | Leave a comment

Personal Update

Most may not realize, but I recently left my old position at SeraCare Life Sciences and moved to athena health (lower case is on purpose).  As sometimes happens in business, SeraCare felt they could do without me and while I didn’t necessarily agree I have to admit my situation has improved quite a bit.  athena health is a cloud based technology company selling EMR–electronic medical records–and claims submission automation.  I think this is a great business model, and judging from their 30% growth over the past 2 years (each year) their clients feel the same way!  athena is quite a bit different from my past positions as it marks my first real return to corporate IT since leaving Sun Life of Canada many years ago–I did have a stint of a 3-month contract working at PC Connection but the commute was just too much–otherwise I’d probably still be there!

It’s interesting how IT changes at scale as the differences to small business are stark.  Petabyte flash-based SAN’s are the standard now, with high-speed Compellant storage being relegated to tier two storage and backups!  I was excited to be getting flash-based drives in a few laptops before.  And I have PowerShell to thank for it!  I was primarily hired because of my script writing talents–though I’m sure 20+ years in the industry didn’t hurt the decision any.  All the hard work in the Spiceworks, PowerGUI and forums, not to mention this very blog have really paid off.

And with the scale of athena health comes interesting side effect to how you have to approach your PowerShell script writing.  When I run a task against all of the users now, its not a report with 150 lines in it, it’s a report with 4,700!  Suddenly, multi-tasking using PowerShell jobs takes on a whole new meaning, as well as taking a different perspective on your script writing.  Often I’ve just done brute force methods because the datasets were so small it just didn’t matter.  That’s no longer an option!

Another cool thing I’ve been working on is re-writing our fax troubleshooting tool.  Have I mentioned faxing as it relates to athena health yet?  I should, because I’ve never seen, or heard, anything like it.  One of the features of athenaNet is we give you, the client, a toll-free fax number and all of your incoming faxes come to us and we place it in your portal.  Sending something out to a lab?  Just complete the form and we’ll take care of the fax to the lab–both sending and receiving.  It’s actually pretty amazing.  And we do a LOT of a faxing.  No, seriously, it’s stunning.  I don’t know the exact numbers but it’s hundreds of thousands of faxes sent and received every day.  We actually went over 1 million faxes a couple of weeks ago.  The infrastructure for just our faxing environments is larger than most companies entire data centers!  We have 2 “environments”, A and B and three data centers.  Each data center has 8-12 servers PER environment so that’s a whopping 48 to 60 servers–I’ll have to do an exact count at some point–just to support faxing.

So a fax troubleshooting tools is a given.  One of my first projects walking into the door was to fix the one we had, which was written in ASP.  Now, I told the boss right off the bat, “you realize I don’t know ASP, right?!”  He was fine with it and was actually looking to do something in PowerShell first, then putting some kind of web front in on it later so we can roll it out to the account managers.  I’ll be writing about how I accomplished this in a future post, but I mostly just copied Boy Wonder here, so feel free to look through his stuff in the mean time.  With some tweaking this actually ended up working really well.

Anyway, I am still around and I am still writing when I can.  Luckily things are starting to slow down a little bit so I can start thinking about the blog again.  FYI, I’m doing a beginner’s guide to PowerShell for the Boston Spicecorps on July 24th so if you’d like to check it out make sure to sign up for Spiceworks and get yourself registered!

June 18, 2014 Posted by | General, Random Thoughts | 2 Comments

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 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


Get every new post delivered to your Inbox.

Join 218 other followers