the dirty dozen: windows powershell scripts for the busy dba ike ellis
TRANSCRIPT
The Dirty Dozen: Windows PowerShell Scripts for the Busy DBAIke Ellis
DBI331
Talking SQL Server from PowerShell
There are several different approaches to working with SQL Server from PowerShell
.NET
SMO
Cmdlets
SQL PowerShell ADO.NET
Windows PowerShell
SQL Provider
WMI
The SQL Server 2012 PowerShell Provider
Once you’re inside the SQL Server Provider for PowerShell you have a lot of options besides just working with databases inside of the Relational Engine
Analysis Services
Data Collection
Integration Services
Registrations
Utility
Policy Management
Server Extended Events
Database Engine
PowerShell for SQL ServerTraversing the SQLSERVER:\SQL\ Provider 101
If you know how to navigate Object Explorer in SSMS you already know how to navigate the SQL Server PowerShell Provider
To navigate to an instance it looks like this:SQLSERVER:\SQL\LocalHost\Default\DatabasesTo get to a named instance on a remote server it’s like this:SQLSERVER:\SQL\ProdSQL01\R2\Databases
SQLPSXmake things easy on yourself. Download this now!
First: Don’t Script, write PowerShell Functions instead
http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/26/don-t-write-scripts-write-powershell-functions.aspx
Second: Don’t write code directly against the SMO if you can avoid it.
Chad Miller is better than you. See for yourself…CodePlex: SQLPSX.codeplex.com
12 for 2012
12 PowerShell scripts for working with SQL Server 2012
Track Resources
@sqlserver@TechEd_europe
#msTechEd
mvaMicrosoft Virtual Academy
SQL Server 2012 Eval Copy
Get Certified!
Hands-On Labs
Resources
Connect. Share. Discuss.
http://europe.msteched.com
Learning
Microsoft Certification & Training Resources
www.microsoft.com/learning
TechNet
Resources for IT Professionals
http://microsoft.com/technet
Resources for Developers
http://microsoft.com/msdn
Evaluations
http://europe.msteched.com/sessions
Submit your evals online
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to
be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS
PRESENTATION.