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.
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].
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!
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.
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.
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.
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!
I’ve been thinking a lot about this lately. What, you ask? How to approach writing a script or advanced function. Most of the time I’ve always in the accommodate world, where I try to imagine every scenario that might happen and account for that in my script. But is this the right approach? Should I instead simply dictate that this is how you use the script? A lot of people do it (VMware requires Connect-VIServer before you do anything). Should I start doing the same?
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.
I’d been writing PowerShell scripts for a couple of years before I came to athena health, and had a pretty good feel for how I liked to do things. I knew about Transcript logging, but it was so inelegant. Most of the time it didn’t capture much anyway because I really do believe in running clean scripts. A good script shouldn’t have any problems, just run and not really return any feedback. Especially if it’s running as a scheduled task–no one’s there to read it anyway! And that’s the rub, if you’re not there to see what went wrong, how do you troubleshoot it? Logging, of course!