770
Part V: Enterprise Data Management
Why Use PowerShell?
In today’s business world it’s important to get as much done in as little time as possible.
The most successful people fi nd ways to automate every repetitive task for which they’re
responsible. Consistency is important when automating tasks so that every administrator
on the team is equally capable of stepping in to help other team members when necessary.
Microsoft has designated PowerShell as part of its common engineering criteria (CEC) for all
server products. This means that an administrator who’s responsible for Exchange or Active
Directory probably has spent time learning PowerShell, and scripts written to manage SQL
Server using PowerShell can be understood by administrators without specifi c SQL Server
knowledge. Companies can run more effi ciently with this common scripting language, and
administrators with skills in PowerShell are more valuable to their companies.
What’s New with PowerShell in SQL Server 2012
SQL Server 2012 brings not only improvements for SQL Server; it also brings an upgraded experience
inside PowerShell 2.0. You no longer have to deal with multiple snap-ins to load all of the func tionalit y
for working with the relational database engine.
■ (^) Single Module for SQL Server
■ (^) A new Module for SSAS
■ (^) Ability to browse SSIS & Extended Events
Basic PowerShell
PowerShell, like any language, consists of commands, variables, functions, fl ow control
methods, and other features necessary to enable work to be done. Because it is an inter-
preted language, the scripts don’t have to be compiled into an executable form to be run.
Language Features
A cmdlet (pronounced “command-let”) is a command-line utility built into PowerShell to
provide some functionality. These cmdlets use a verb-noun naming convention, so it’s easy
to understand what they’re doing. Microsoft has provided approximately 236 built-in cmd-
lets with the default installation of PowerShell (2.0), and additional cmdlets are installed
depending on various server products that may be running. PowerShell 3.0 will be available
in late 2012, but because it wasn’t ready for release when SQL Server 2012 was shipped, the
focus of this chapter is on PowerShell 2.0. (Version 3.0 expands the PowerShell language
and introduces a more powerful integrated scripting environment, similar to Visual Studio.)
All future development should take place inside the PowerShell 3.0 ISE if you have access to
it. Its many built-in features are far superior to the simple console window.
c30.indd 770c30.indd 770 7/31/2012 9:46:21 AM7/31/2012 9:46:21 AM
http://www.it-ebooks.info