The Surly Admin

Father, husband, IT Pro, cancer survivor

New Module: SimpleADAdmin

Another day another module.  Using PowerShell Gallery to publish modules and make them available to all is really a game changer.  I’ve been finding myself repackaging old scripts into modules and publishing them (see PSHTMLTools) and SimpleADAdmin is no exception.  It’s basically Get-SAUser but now in a module.

Checkout out the blog post about it, and you can read the documentation on Github. Installation is easy:

Install-Module SimpleADAdmin

In the future, I want to add Get-SAGroup to the module to allow you to manipulate and locate groups much easier.  Enjoy!

Advertisements

May 23, 2019 Posted by | PowerShell | , | Leave a comment

New Module Published: PSHTMLTools

Before I get started, just wanted to check with you that you’re ok?  It’s been a long time since I posted here and it probably came as a shock.  Work at athenahealth has been incredibly challenging and to be honest, when I get home I just want to spend time with my family and not hours MORE behind the keyboard coding!  I’ve also taken up hiking–when my back allows–and am the proud owner of a blue Tesla Model 3!  And, in a stunning turn of events, my daughter has become a teenager.  I have no idea how that happened.  That said, I got the bug this weekend after a Github contributor put in a Pull Request to my old Set-CellColor function.  I wish I could have accepted the PR, but I ended up reworking the script to squash a long standing bug.  Then I added CI/CD and Pester testing.  Ah, screw it, let’s make a module!!

Introducing PSHTMLTools

This is a module of the 3 HTML tools I use–almost exclusively–for my reporting at work.  They are designed to work with ConvertTo-HTML, and while they might work with HTML tables created from another source, it’s not their purpose.  The 3 functions, you ask?

  1. Set-AlternatingRow
    • This is a simple function that will alternate between two CSS classes for each row of a table.  You supply the CSS and the classes and just tell the function what they are.
  2. Set-CellColor
    • This function will take a Filter that you supply (Column4 -eq 5) and if it finds a cell in that column that matches your criteria will change its color to what you tell it to.  This is great for reports where you want to highlight when some threshold is crossed, like 90% license usage.
  3. Set-GroupRowColorsByColumn
    • This will change the color of a row whenever the value of a column changes value.  Say you have a report that has 2 or 3 lines for each server, you’d group by the server name and get a different color every time the report moves on to a new server.  This one makes for especially slick looking reports.

That’s it.  I enjoyed making a full CI/CD pipeline for this module with a full suite of Pester tests and automatic publishing to PSGallery.  To install it you can simply install it from the PowerShell Gallery:

Interested in contributing? You can find the project on Github here.

 

February 25, 2019 Posted by | PowerShell - HTML Reporting | | 1 Comment

Active Directory Operational Testing

One of the things I’ve been working on lately is some kind of operational testing for Active Directory.  It’s such a reliable product that as Administrators we tend to neglect it.  Then Irwin Strachan came up with his Active Directory tests using Pester, and this was the first time I’d seen Pester used in something other than code testing and it really got the mind turning.  So when we started getting really serious about monthly capacity planning at athena health then I wanted to do this kind of testing for our Active Directory.

Continue reading

November 28, 2016 Posted by | PowerShell | , , | Leave a comment

Calculating the Quarter

Quick post since it’s been awhile since I’ve done anything.  I’ve mentioned before but I do a lot of reports, and I recently got one to do some calculations for 95th percentile–well, kind of.  The funny thing was the person who asked me was supposed to be making a solution themselves, kind of homework from the boss but they didn’t mention it to me and I thought it would be a fun challenge so I went and wrote up a script that could do it, parameters and everything.   Oops!  Anyway, when done they loved the report so I streamlined it from taking 10 minutes to run to about 1 or 2 (all in SQL, no PowerShell) and thought I was done with it.  Then came the ask, not only do they want that data for the month, they want it for the whole quarter!  So now I had to figure out which quarter I was in and what the date range for that would be.  Yeah, I could put it in by hand, but there’s no challenge in that.

First came a Google to see if someone could do it in a one liner, and sure enough Vinoth over at StackOverflow had some great maths for that.  Now calculate the dates and the easiest way was to simply create a little loop 1 through 4 and calculate my dates:

First use Get-Date to get the January 1st, then loop 4 times adding 3 months each time to get the date ranges.  Now to get a date range for the current quarter?  $Quarters[$Quarter].

 

November 15, 2016 Posted by | PowerShell | , | 1 Comment

Simple Day to Day Administration

Been so long since my last update!  Why haven’t I posted more?  Well, for one I’m usually so tired from coming home from work I just don’t have any extra energy for PowerShelling.  Another factor has been there are so many people doing so many interesting things I just couldn’t find anything that someone else wasn’t already doing much better than I am.  The last bit is having an interesting project to talk about.  I’ve been doing a lot of things at work, but it had to do with Windows cluster node moves, SQL Availability Group moves and so on.  But ultimately the scripts become pretty specific to athena so it’s difficult to translate for general use.

I think I finally have something interesting, though, with Get-SAUser so read on!

Continue reading

August 11, 2016 Posted by | PowerShell | , | 1 Comment

PSNetScaler Module

I’ve been working a lot lately on our load balancer, a Citrix NetScaler 7500 to be specific.  Since we upgraded the to version 10.5 (and got rid of that crappy Java interface) the web experience is actually pretty pleasant and I do most of my work there.  If I have a lot of changes I occasionally drop into the CLI, but mostly I’m on the web interface.  That said, I love me some PowerShell and I thought wouldn’t it be amazing to have some PowerShell cmdlets?  Read on to see how the PSNetScaler module was born.

Continue reading

March 11, 2016 Posted by | PowerShell | , , | Leave a comment

A Practical Guide to GitHub for the PowerShell Scripter

When I first started dipping my fingers into the GitHub pool, it was because I really felt there was a need.  Version control was becoming an issue and having to re-write code I’d already perfected because of a glitch somewhere on the way–translation: accidentally deleting the wrong file–was something that just had to be addressed.  And, I think like a lot of PowerShell scripters, I soon started asking questions like:  WTF is this?  What is going on?  Who came up with this crap?  I’m no expert, but read on if you’re interested in learning how to use PowerShell and GitHub together.

Continue reading

February 22, 2016 Posted by | PowerShell, Technical | , , , , | 1 Comment

Announcing the PS.SQL Module

I’ve been doing a ton of work with SQL and PowerShell over the last year and a half and have come up with some pretty good tools to help me along the way.  We even built a module out of them at work and use it in a dozen or more scripts every day, when it finally occurred to me that my readers might like to use them too.  And the PS.SQL Module was born.

Continue reading

February 19, 2016 Posted by | MS SQL, PowerShell | , , , , | 2 Comments

Count Unique OS’s Per vCenter

Saw a fun little challenge from The Ginger Ninja, here.  The idea was to use PowerCLI and find out how many unique OS’s you have on your Virtual Center server.  Of course, this requires you have a VMware environment, so for the rest of you–sorry!

Continue reading

January 16, 2016 Posted by | PowerShell | , | Leave a comment

Updated SQL Queries

Awhile back I wrote the Invoke-SQLQuery script, it’s a light-weight easy way to query a SQL database and get data back.  It’s primary appeal over just using Invoke-SQLCMD was there is no need to install anything, just run the script, get your data and go.  Easy, peesy.  Now it’s time for a big update in capability.

Continue reading

November 18, 2015 Posted by | PowerShell | , , | 5 Comments