0

Monday Coffee: Should I learn powershell?

This month’s T-SQL Tuesday’s topic was set by Rob Sewell (b|t) and entitled Let’s all get PoSH

It had a massive response with loads of people writing about how they use powershell to automate tasks in their day to day work.

(Shameless self promotion – I wrote a post about how to create VMs with powershell, you can check it out here)

It was really cool to see how everyone uses powershell and for me answers the question “Should DBAs be learning powershell?”

Yes, yes you should.

I’d actually go further and say that you need to be learning powershell if you want to get anywhere in your career as a DBA. It’s a tool that in my opinion, every DBA needs. Yes you can get by without it but then you’re limiting your skills.

Here’s some of the posts that should give you an idea of how powershell can help you out: –

Daily database copy using Powershell
Disabling the named pipes protocol for SQL Server using Powershell
Using Invoke-SQLCmd to run SQL Jobs Remotely
Automation Through PowerShell Checking the Status of AGs
Turn on/off Azure VMs with Powershell

That’s a wide ranging area that powershell can help in, right? Pretty much anything you do as a DBA can be run in powershell. If you type something more than once? Hey, guess what!?

So if you’re not working with powershell, I highly recommend that you start looking into it. You’ll find a whole load of cool stuff that you can get into, from basic functions to modules like dbatools

One piece of advice for when you start writing…if it works, it works. Oh, and get your scripts reviewed by someone. It helps in ways you won’t even think of.

Remember that we’re all learning this stuff.

For example, I’d consider myself fairly decent at writing powershell scripts and recently asked a friend of mine to review a script I wrote. Here’s his response: –

Andrew, powershell is a beautiful language and you, are butchering it…

Ouch! 🙂

Thankfully he followed that up with a whole bunch of good tips on how I could improve my code.

But the point is, we’re all learning and there’s a whole bunch of people out there ready to help. So, give it a go and see what you can script.

Have a good week!