The Surly Admin

Father, husband, IT Pro, cancer survivor

New Version: Employee Directory

I keep getting requests “Can I get this field?” or “Can I get that field?” for the Employee Directory script and honestly it wasn’t designed for that.  The header in the table has to be manually changed, and the JavaScript that does the button filtering has to be altered.  Not to mention the reverse engineering that has to occur because I don’t necessarily remember everything I did in the script 6 months ago!  So it was time to sit down with the script and see if there was something I could do about this.  Here’s what I came up with.

Continue reading

May 16, 2013 Posted by | PowerShell | , , | 121 Comments

Custom Employee Directory Update

The other day Richard Hipkin over at Spiceworks requested a custom version of the Employee Directory that I blogged about last week.  The irony, and isn’t this always the case, is that he wanted something I had removed from the original vbScript that had been there!  Richard wanted to add Location as well as the employee’s manager into the mix.  Normally this would have been pretty simple and I would have just sent it over to him without comment but I ran into an interesting problem that I wanted to write about here.

Continue reading

October 25, 2012 Posted by | PowerShell | , | Leave a comment

Employee Directory with Photo’s Part 2

Part two of my talk about converting my Employee Directory with Photo’s vbScript into Powershell.  Part one here.

Continue reading

October 18, 2012 Posted by | PowerShell | , | 1 Comment

Employee Directory With Photo’s Part 1

One of my favorite projects this last year was creating an Employee Directory with Photo’s webpage.  Of course, with me it’s never enough just to create a static page, it needs to be coming straight from a central database like Active Directory.  This was a tough project because it also involved using Javascript on the page itself to do some on page searches.  I know very little Javascript and found it very challenging to figure this part out, and even had to reach out to the Spiceworks community for some help (thanks Snozzberries) on some of the coding.  Written in vbScript it was 383 lines of goodness.

But I’m all about Powershell now, and it was time for a re-write!

Continue reading

October 15, 2012 Posted by | PowerShell | , , , | 6 Comments

Opening up my Scripts

I have a confession to make.  I’m really busy at work.  So busy, and challenged, that I haven’t had much time to keep the blog going and certainly not enough time to help support all the scripts I’ve written.  In fact, if you’re subscribed to the Employee Directory post, you’ve seen the back and forth going on there!  I feel really bad that I haven’t been able to get back to the few of you who have reached out to me because you’re running into problems, but the work/life balance is a little skewed right now and the blog and supporting you is what’s had to drop off.

The other problem is I don’t have the infrastructure around to support some of the scripts, the DFS Monitor comes to mind!  No DFS here at work so hard to test!

So what to do?  I want people to enjoy my scripts and I’d like to continue seeing development happen on them.  So time to get these things out on GitHub.  This way if you want to make changes you can fork the code off and do your thing and even put in a pull request–I swear that should be a push request, but that’s just me–and if I like what I see I’ll merge it in with the main code.

You can find me here, and the scripts I’ve published so far:

That’s all I have right now, but if there’s a script you’d really like to see up there just let me know in comments and I’ll get it posted ASAP.  I hope this helps!

 

 

April 14, 2015 Posted by | General, PowerShell | , , | Leave a comment

ConvertTo-AdvHTML – New Advanced Function for HTML Reporting

I love using ConvertTo-HTML.  There, I’ve said it.  The vast number of scripts I write are doing some kind of reporting function and the ability to create simple, fast, yet good looking reports with HTML has been a huge plus for PowerShell.  That said though, there’s definitely room for improvement.  ConvertTo-AdvHTML is an advanced function that addresses some of the current limitations with current cmdlet.  But this blog post isn’t going to a long explanation of how to use the new cmdlet, instead I wanted to write a script that actually used it.

Continue reading

February 27, 2014 Posted by | PowerShell - HTML Reporting | , , , , | 14 Comments

Flying out to SpiceWorld 2013

Well, it’s 5am and I’m flying out to Austin, Texas for SpiceWorld in just a few hours.  Can’t seem to make myself relax and get some much-needed shut-eye so why not write something here?!

So tomorrow is the big day for Rob and I’s PowerShell introduction session and I’m really pleased with how the presentation came out.  It’s going to be interactive as we build a tiny script with the audience.  There are only about 9 slides and 3 of them are introductory and 1 is an “Any Questions?” slide.  The rest is just to get us to the script writing stage.  I don’t know about you, but any presentation that drones on with a ton of slides, especially when the speaker is essentially just reading off the slide, is usually not a good presentation!  I think Rob and I have managed to avoid that with this one.  The session itself is only 45 minutes and if you’ve done anything with PowerShell you know that’s not nearly enough time to even really get you started so we’re focusing on giving you the tools to write your own scripts using the three base commands:  Get-Command, Get-Help and Get-Member.  I’ve written before about all three before here in my Getting Started series.

I’ve written a few scripts recently that I’m pretty proud of that I wanted to mention:

Get-DiskInfo – Really PowerShellisk type script for getting disk information from your servers and workstations.  Accepts all kinds of pipeline input and outputs objects, both a default set and more extensive information if you use Get-Member.

Export-PrinterInfo – This is a script I’ve had for quite a while that I wrote for someone on Spiceworks but ended up using at work too.  Finally decided to publish it on Spiceworks.  It’s a pretty comprehensive disk information script that saves everything to an Excel spreadsheet.

Send-PasswordExpirationNotifications – Just released this script.  It’s an update of a successful vbScript I wrote a few years back that will send users an email when their password is getting ready to expire.  It uses an old-fashioned INI file for configuration but really allows you a lot of flexibility.  Depending on how much effort you put into it you can really customize your outgoing notification so one usage of the script can be totally different looking from another.  All without touching a bit of code!  It also fully supports fine-grained password policies for those of your who use those.

With the experience of using an INI file I gained from the Send-PasswordNotifications script I also have a new version of the Employee Directory ready.  This script has some complex configuration requirements that parameters can handle, but they’re not necessarily user-friendly.  I really struggled with the decision on whether to use named parameters–which would be much more in keeping with PowerShell best practices–or going with an external configuration file.  I decided to stick with best practices, but in the real world of testing and changing the script I’ve found the parameters to be unwieldy.  Therefore the changeover to a configuration file.  Haven’t published it just yet because I want to test it in the real world first and I had one technical issue that I managed to code around but I’m not convinced it’s the best way of going about things.  If you’d like to take a look at the problem and help me out, please feel free to take a look and let me know your thoughts!  The thread can be located here.

OK, just about time to get ready for my flight!  Wish me luck and I look forward to meeting you at SpiceWorld and I hope you come to the PowerShell breakout session, even if you’re a pro!

October 28, 2013 Posted by | General | | Leave a comment

Simple Server Status

A little while back the Microsoft Scripting Guy, Ed Wilson, blogged about creating a simple web page with server uptime.  It was an interesting use of some of the Powershell capabilities and the output was pretty good, if a little uninspiring–not his fault I might add, more a limitation of the Powershell tools he was trying to use.  I didn’t do anything about the script at the time, but it always intrigued me.  Then the other day a very similar request came across on Spiceworks.  At first I just gave the guy the same link I put above, but now the bug was in my ear and I decided to write something up.

Continue reading

October 11, 2012 Posted by | PowerShell | , , | 7 Comments

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 | , , | 34 Comments

User Termination Automation – Part 1

Having written about New User Automation here and here, it only made sense to start working on User Termination Automation.  Read on to see how I accomplished this.

Continue reading

December 27, 2012 Posted by | PowerShell | , , | Leave a comment