Book Review – Windows PowerShell 3.0 Step by Step” by Ed Wilson;O’Reilly Media, Inc.

Today I will talk about a book  titled  ” Windows PowerShell 3.0 Step by Step” by Ed Wilson;O’Reilly Media, Inc.


When I first heard that Ed Wilson is writing a book on Windows PowerShell I was greatly excited. I am a great fan of PowerShell and by all means Ed is the right person to write a book on it.

I am a great fan of his blog too.

My rating for this book is a full five !


I consider this book as my PowerShell Bible, and its been always a reference guide for me since I started reading it for the first time.

First of this book talks about the latest version of PowerShell,ie 3.0.  The book is well organized into 3 sections.

First section talks about Windows PowerShell overview and its fundamental role.

Second section covers Windows PowerShell scripting.

Third section covers specific applications such as AD, Exchange etc.

There are very clear instructions to find your best starting point for this book, however if you are really new to PowerShell, then reading the whole book is definitely recommended.

Whole lot of good exercises are made available at the end of each chapter which will ensure that you learn the concepts really well.

When I started reading the initial chapters I was wowed by the amount of tips/tricks provided by the author for his readers. There is a PowerShell script which is provided for every tip which can be leveraged by the reader for his/her use. These tips/tricks are always useful for users who started of with PowerShell recently and also it will come handy for expert users.

Example – Chapter 1 talks about a script which will add both the Windows PowerShell ISE and the Windows PowerShell console to both the Start screen and the taskbar on Windows 8.

There are plenty of tips available in the book which will be well appreciated by both beginners and experts.

Here is a quick glance of what each chapter talks about –

Chapter 1  – Empowers the reader to get started with PowerShell and explains a great deal of information on how sufficient help can be obtained for cmdlets.

Chapter 2 – Talks a great deal about cmdlets(The heart and soul of PowerShell).

Chapter 3– The focus of this chapter is on Power Shell providers. There is great amount of details available in this chapter.

Chapter 4 – This is one of my favorite chapter of this book. This chapter talks about capability of PowerShell to do remote connections and run commands for a remote system.

Chapter 5 – Is all about scripting. There are lot of real world examples and that’s the beauty of this book.

Chapter 6,7– All about functions and modules.

Chapter 8 –  Great amount of changes was happened for PowerShell ISE in 3.0(Integrated Scripting Engine) and this chapter deep dives into ISE.

Chapter 9 – I consider this chapter very important. This chapter talks about Profiles and trust me, there are a lot of good examples provided.

Chapter 10,11,12 and 13 – Great resource for learning WMI. Again one of my favorite chapters and anytime reference point.

Chapter 14 – Talks about CMI Cmdlets.

Chapter 15,16 and 17  – If you are a Windows Admin,then you just cant afford to miss reading these chapters. These chapters provide you with great deal of information on managing AD(Active Directory) with PowerShell.

Chapter 18 and 19 – Talks about debugging scripts and handling errors. Great resource to ensure that PowerShell scripts are error free.

Chapter 20 – Focuses on Exchange administration.

Where can you download this book

You can download the book from and do a search using the title or you access here to get you routed directly to this book.

Print ISBN:

978-0-7356-6339-8 | ISBN 10: 0-7356-6339-4

Ebook ISBN:

978-0-7356-6337-4| ISBN 10: 0-7356-6337-8


This book by all means is worth every penny and any IT professional would love to get a copy of this book and maintain it as a reference.

Thanks for reading and keep watching this space for more.

Get Database information in mail using PowerShell !

Would you love to get a weekly status report of all the databases hosted on your mission critical servers? ,Would you love to get a report which will help you maintain and manage your large shared SQLServer environments neat and clean?

If your answer is Yes, then powershell is your solution. Welcome to the world of powerful powershell(Well, that sounds like a good marketing buzz word !).


Lets’ think about a large enterprise situation where in you are managing a huge SQLServer shared server which has many databases. Each day your DBA team members will be adding new databases to the server, and you would like to get a status report to ensure that the databases are compliant to the regular database ‘rules’ as you are responsible for the well being of the environment.

Example – No database can have a compatibility level which is less than 110,No databases can have owner other than SA etc.

I’m a great fan of the articles written by Microsoft Scripting Guy, Ed Wilson(B) and one of his articles gave me a quick idea of deploying a powershell function which will pull the database details on a weekly basis.

I slightly modified his code mentioned in the article here (This is a very useful/detailed article, and I highly recommend this to everyone ) and my little function will pull database information such as Name,PageVerify,CompatibilityLevel,Size,LastBackupDate,Recoverymodel,Owner etc and will send across an email.

Note – All credits goes to Ed for his original code. I have great respect for Ed,and if you are interested in powershell, then I highly recommend reading his articles.

Here is the powershell function   –

#Remember to make changes for SMTP area

Function Get-DBInfo ($SQLInstance)


    if ($SQLInstance.Contains(“`\”))

        { $location = “SQLSERVER:\SQL\$SQLInstance\Databases” }


        { $location = “SQLSERVER:\SQL\$SQLInstance\DEFAULT\Databases” }

    $style = ‘<style>’

    $style = $style + ‘BODY{background-color:peachpuff;}’

    $style = $style + ‘TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}’

    $style = $style + ‘TH{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:thistle;font-size:16}’

    $style = $style+ ‘TD{border-width: 1px;padding: 5px;border-style: solid;border-color: black;background-color:palegoldenrod;font-size:14}’

    $style = $style + ‘</style>’

        $body=dir -force  $location | where-object {$_.Name; $_.Refresh()} |

        Select Name, CompatibilityLevel,Pageverify,Size,LastBackupDate,RecoveryModel,Owner |ConvertTo-Html -Head $style -Property Name,CompatibilityLevel,Pageverify,Size,LastBackupDate,RecoveryModel,Owner |Out-String

        #Set your smtpserver information

        Send-MailMessage -To “” -Subject “Database Details from SQL2012 – Notification” –From “” -SmtpServer “” -Body $Body -BodyAsHtml


Get-DBInfo SQL2012

<Modified 01/27/2013> Above code was modified to pass the correct variable <Modified>

If you schedule this function as a SQL Job then you will receive automated emails according to your requirements.

Here is a sample email which was generated by the Get-DBInfo function.

Powershell Notification


Automated reports is going to help DBAs a lot and powershell is making life more easier by helping us to create highly flexible functions.

Thanks for reading and keep watching this space for more.

Powershell 3.0 is here ! – Windows Management Framework 3.0 – RC

Couple of days back Microsoft released Windows Management Framework 3.0 Release Candidate which includes Power shell 3.0.

Download files and what’s new can be referred here.

One of the first changes I noticed with this release is feature rich ISE. The new interface looks really nice with commands add-on which will list commands for each and every module.

You can install WMF 3.0 for the below flavors of operating systems –

Windows 7 Service Pack 1 – Both 64bit and 32bit

Windows Server 2008 R2 SP1 – Only 64bit

Windows Server 2008 Service Pack 2 – Both 64bit and 32bit

I am running a Windows Server 2008 R2 SP1 box and the setup upgraded my existing power shell 2.0 environment to 3.0.

You can find Commands add-on view available on the right hand side of the ISE which is pretty useful.

IntelliSense is also turned ON for ISE, and it’s one of the best features I would always love to have as I am still learning power shell basics.

There is some customization available for the ISE under Tools section. The below screen shows customization for the scripting pane.

The Add-On tab in ISE will directly take you to the Microsoft tech net site which will provide the add-on files for the ISE.


Power shell 3.0 comes up with a real strong ISE which is really helpful for power shell beginners (Like me) and during the coming days I will leverage more and more options with in Power shell 3.0.

Happy scripting.

Thanks for reading.

Out-GridView cmdlet – Interactive table

One of the very interesting cmdlet which I came across today was Out-GridView.This is really powerful and it sends across powershell script output to an interactive table.

I prefer this option as I can slice and dice the data if required.

Out-Gridview requires Microsoft .Netframework 3.5 with SP1.This applies for Powershell 2.0.

Below is the Out-GridView of one of the powershell script which pulls Backup information of SQL Server databases.


This interactive table gives you an option to Add a criteria,and using that criteria you can filter the results.

Example – We are adding the criteria ‘Database Name’ and entering starting characters of Adventure works will filter out the data for you.



This interactive table will be really useful when you are dealing with a lot of data and you need to filer out the same.Exporting the data to a spreadsheet is one option,however for quick slice and dice Out-GridView is the cmdlet for you.

Thanks for reading.

Powershell 2.0 for Windows XP – How can I get this up and running

Recently I had to work with Powershell on a windows XP machine and I was wondering how to to set this up.I had never worked with Powershell on XP and was curious on how to configure it.

I was able to find a KB article for Windows Management Framework which included Powershell 2.0

I was able to find the correct product and downloaded the same.

The install went smooth and a reboot was not forced.I was back running with powershell on windows XP again.

Thanks for reading.

[Update Added on 03/30/2012 – Powershell pre installed on Windows 7 and Windows Server 2008 R2]