| Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia...

16
| Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia [email protected] MVP & MCM SQL Server

Transcript of | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia...

Page 1: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

| Lausanne

SQL Server et PowerShellDavid BarbarinDatabase Architect - [email protected] & MCM SQL Server

Page 2: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Business Intelligence

Data Management

Collaborative Solutions

Enterprise Content Management

Social Business Services

Business Solutions SharePoint

SQL Server

Dynamics NAV CRM

insentia en quelques mots55 collaborateursMembre de VeltigroupPrésence Suisse

Genève, Lausanne, Bern, Zurich

Page 3: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Agenda

Avantages et inconvénients 5’

SMO et fournisseur SQL Server 15’

Cas d’utilisation 35’

Page 4: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

| Lausanne

Avantages et inconvénients

PowerShell et SQL Server

Page 5: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Historique

Avec SQL Server 2008 Utilisation d’un mini-shell sqlps avec limitation d’utilisation

Avec SQL Server 2012 Le mini shell n’existe plus et sqlps peut être chargé en tant que module

Environnement Power Shell plus complet Possibilité de charger d’autres modules ou snap-ins

Page 6: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Avantages et inconvénients

Inconvénients Prise en main de PowerShell peut être compliqué pour les DBA non développeurs Peut rendre plus complexe les opérations DBA au jour le jour. L’utilisation de T-SQL

est plus adapté dans ce cas

Avantages Langage commun d’administration des serveurs Windows (Windows, Exchange,

SharePoint, SQL Server …) Environnement de script étendu à l’utilisation du Framework .NET Accès aux ressources externes à SQL Server contrairement au langage T-SQL Possibilité d’exécuter les requêtes T-SQL par l’utilisation de cmdlets ou objets SMO

Page 7: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Exemple de cas d’utilisation

Inventaire d’instances SQL Server

Provisionnement semi-automatisé d’instances SQL Server

Template de création d’objets SQL Server pour des super utilisateurs non DBA

Rafraîchissement de bases de données entres différents environnements (production test)

Automatisation de vérification de la gestion des règles (Policy Based Management)

Formatage de résultats en sortie d’un benchmark SQLIO

Monitoring

Page 8: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

| Lausanne

SMO et fournisseur SQL Server

PowerShell et SQL Server

Page 9: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Server Management Objects (SMO) SMO est une librairie .NET contenant un ensemble d’objets, propriétés, méthodes,

interfaces, énumérations etc… permettant de travailler avec SQL Server

Le modèle objet montre l’ensemble des objets utilisables et leurs relations intrinsèques

Tous les objets du modèle héritent du nœud racine « Server»

Diagramme : http://bit.ly/smodiagram

Namespace : http://bit.ly/smonamespace

Page 10: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Server Management Objects (SMO)

Page 11: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Fournisseur SQL Server

PSSnapin (2008 et PowerShell V1) SqlServerProviderSnapin100 SqlServerCmdletSnapin100

Import module (2012 et PowerShell V2)

Cmdlets pour SQL Server

Permet la navigation comme dans une structure de dossiers / fichiers pour interagir avec SQL Server

Types et formats

Page 12: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Mapping fournisseur SQL - SMO

Page 13: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

| Lausanne

DEMONSTRATION

PowerShell et SQL Server

Page 14: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

Cas d’utilisation

Installation automatisée d’une ou plusieurs instances SQL Server

Ajout d’une instance SQL Server dans un serveur centralisé (CMS)

Inventaire d’instances SQL Server

Application de règles de gestion automatisée sur des instances SQL Server

Installation automatisée d’un environnement SQL Server AlwaysOn

Sauvegarde vers Windows Azure

Page 15: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

| Lausanne

Merci de votre écoute

Page 16: | Lausanne SQL Server et PowerShell David Barbarin Database Architect - Insentia david.barbarin@insentia.ch MVP & MCM SQL Server.

© 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.

© 2013 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.