SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get-DbaPowerShell

By Steve Jones,

When I first saw PowerShell, at TechEd 2006 (ish) and I was enamored. This was a much better environment than VBScript for working in a shell. Then I realized I needed -eq, -gt, etc. and was less excited. These language elements felt like a step back. Then I tried to build a restore script for SQL Server databases early on and was much less excited.

Across the years, I've played with various tasks in PoSh as opposed to T-SQL or simple command scripts in various languages, and I find myself going back and forth. PoSh is very useful in some ways, more cumbersome in others, and I still am not sure exactly how I feel about it as a go-to tool. I am coming around to use more PoSh because of the dbatools project, and I find myself considering PoSh instead of T-SQL, especially when I think I may want to work across instances and string together commands.

I was quite excited recently by T-SQL Tuesday #94, hosted by Rob Sewell. The topic was PoSh, and quite a few people participated, as you can see from the Get-PostRoundup. There are some creative uses of PoSh, such as importing Excel data, administering SSRS, turning Azure VMs off, cleaning up orphaned files, and more. Personally, once you start to use Azure more, PoSh makes the portal seem cumbersome and slow, and I find that for recurring tasks, it's a much better tool.

Recently I saw the DBAfromtheCold write a short piece on why you should learn PoSh. It's a good look at some of the tasks that are easy through PowerShell. Some of these could be done in T-SQL, some with other scripts, but PoSh certainly is a possibility and an easy way to manage some of the tasks you might need to do at scale.

I don't think PoSh is the best way to do everything. In fact, I often still lean on T-SQL for many admin things, especially if I already have a connection open in SSMS. However, as I learn more about PoSh and how to use it, I can make those judgment calls about when it's a better fit. That knowledge helps me become a more capable and stronger data professional, because I have choices about how to work with systems, and I have some knowledge or basis for the decisions I make.

I advocate continuing to learn throughout your career, and certainly including PoSh as a topic if you work on the Microsoft platforms.

 
Total article views: 72 | Views in the last 30 days: 72
 
Related Articles
ARTICLE

Why I am Excited about SQL Server on Linux

Read why Solomon Rutzky is excited about SQL Server running on Linux.

ARTICLE

Lots of Learning at SQL Bits

Steve Jones is getting excited about learning at SQL Bits 2017.

BLOG

Better ReadyRoll Script Naming

One of the things that I like about ReadyRoll is that the product will automatically build new scrip...

ARTICLE

Learning About Temporal Tables

Learn about the new temporal table feature in SQL Server 2016

BLOG

Why I’m Not Excited About Hekaton (In-Memory OLTP)

A while back I had written a post about why I’m excited about Hekaton (now called ‘In-Memory OLTP’ –...

Tags
editorial    
powershell    
 
Contribute