![Page 1: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/1.jpg)
The Dirty Dozen: Windows PowerShell Scripts for the Busy DBAIke Ellis
DBI331
![Page 3: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/3.jpg)
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
![Page 4: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/4.jpg)
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
![Page 5: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/5.jpg)
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
![Page 6: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/6.jpg)
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
![Page 7: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/7.jpg)
12 for 2012
12 PowerShell scripts for working with SQL Server 2012
![Page 8: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/8.jpg)
Track Resources
@sqlserver@TechEd_europe
#msTechEd
mvaMicrosoft Virtual Academy
SQL Server 2012 Eval Copy
Get Certified!
Hands-On Labs
![Page 9: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/9.jpg)
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
![Page 10: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/10.jpg)
Evaluations
http://europe.msteched.com/sessions
Submit your evals online
![Page 12: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/12.jpg)
© 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.
![Page 13: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis](https://reader035.vdocuments.net/reader035/viewer/2022062322/56649e685503460f94b63ac5/html5/thumbnails/13.jpg)