the dirty dozen: windows powershell scripts for the busy dba ike ellis

13
The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis DBI331

Upload: angelica-harrison

Post on 12-Jan-2016

222 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis

The Dirty Dozen: Windows PowerShell Scripts for the Busy DBAIke Ellis

DBI331

Page 2: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis

About Me

AaronNelson

[email protected] SQLvariant.com

@SQLvariant

Page 3: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis

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

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

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

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

12 for 2012

12 PowerShell scripts for working with SQL Server 2012

Page 9: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis

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

Evaluations

http://europe.msteched.com/sessions

Submit your evals online

Page 11: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis

My Contact Info

AaronNelson

[email protected] SQLvariant.com

@SQLvariant

Page 12: The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA Ike Ellis

© 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