Skip to content

PoSHpiphany – I’ve seen the light….and it is Powershell


Janice Lee ( blog | twitter ) asked where she should get started with Powershell, and instead of a reply,  I decided to blog about it.

Baby steps

This week has been pretty exciting for me as far as technology epiphanies go. One of the things I love most about learning new IT skills are the “AH-HA!” moments. In this case it’s with Powershell.

On Monday, @MidnightDBA ( blog | twitter ) tweeted that Sean would be leading a “Powershell for complete beginners” webinar as part as Pragmatic Works‘ free training.

I’ve read/tweeted a few blog posts in the past regarding powershell, and always wanted to dive into it. However, I’ve got so many other things I need to learn first, that I figured it’d be one of those “nice to haves” and “I’ll get to it later”. Not any longer! Sean kept it simple,  made it easy to see why / how I could use this in my daily job. It really took away the intimidation factor for someone like me, as I’ve not had much experience with programming languages outside of T-SQL.

Good news…Sean’s presentation is available on demand here.  Watch it!!


"Take on.... Powershell" (?)

I started to see where  I could use it immediately  when Sean started talking about scripting out tables. The timing couldn’t have been better, as this could really help me in a current project I’m working on!

MidnightDBA ‘s Powershell #awesomesauce post shows how easy it is:

There are SMO solutions, but there’s a definite efficiency, elegance, and convenience to having everything you need in a single line of code.

dir | %{$Table = $_.Name; $_.script() | out-file c:\$Table.txt}

Start SQLPS from within SSMS 2008 (just right-click your database of choice in the Object Explorer, and “Start Powershell”). The SQL Server Powershell will open, with the path to your chosen database already loaded.

Later on that day…

Meanwhile....back at SQLPass HQ...

Figuring that it’s best to strike while the iron is hot, I decided to attend  Chad Miller’s ( blog | twitter ) SQL Pass App Dev Virtual Chapter presentation on “ETL with Powershell” that same day.

Chad definitely covered a lot, and it was a great complimentary follow up to Sean’s presentation. I liked his logical approach and explanation for using powershell for non-complex ETL tasks.  He discussed more than just ETL, and I saw more ideas that  I could use immediately.

One of his examples showed was how little code it took to get disk space, and other info from a server via WMI-Object calls. He’s automated this within SQL Server by creating a job.  You can view his presentation on demand here along with the slide deck and code examples here.

Moving forward

I’m happy that I decided to participate in those sessions, and am messing around with some of the useful code examples (using Quest’s Power Gui). I also found this example via The Lazy Admin, which I thought was cool. It’s getting a list of running processes, then piping the results out to html.

I requested some advice on good Powershell books, and @SQLVariant ( blog | twitter ) was kind enough to provide me with some suggestions:

Windows Powershell: Best Practices

Windows Powershell in action (FYI, there is a 2nd edition coming out soon, covering 2.0)

@SQLVariant has some great Powershell links from his blog, check it out.

On that note, @Dave_Levy ( blog | twitter ) also has some great resources for those asking the question “Where do I start with Powershell”?

Hope this helps!

Leave a Comment

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: