Powershell und SQL na wie geht das denn?



Similar documents
Microsoft Certified IT Professional (MCITP) MCTS: Windows 7, Configuration ( )

Upgrading Your Skills to MCSA Windows Server 2012 MOC 20417

Digicomp Microsoft Evolution Day MIM 2016 Oliver Ryf. Partner:

WolfTech Active Directory: PowerShell

Installing SQL Server 2012 on SMB Shares on NetApp Storage

Administering a SQL Database Infrastructure

Administering a SQL Database Infrastructure 20764; 5 Days; Instructor-led

Update to V10. Automic Support: Best Practices Josef Scharl. Please ask your questions here Event code 6262

Administering a SQL Database Infrastructure (MS )

How To Get A New Version Of Windows (Windows 8.2) From A Windows Server (Windows) To A Windows 7.1 And From A New Windows 7 (Windows 7) (Windows Server) (Powerpoint

This module explains the Microsoft Dynamics NAV architecture and its core components.

SQL Server 2012 with PowerShell V3 Cookbook

How To Install A New Database On A 2008 R2 System With A New Version Of Aql Server 2008 R 2 On A Windows Xp Server 2008 (Windows) R2 (Windows Xp) (Windows 8) (Powerpoint) (Mysql

Microsoft Office Specialist. Windows 7 Zertifizierungsund Upgrade-Pfade. Microsoft Office Specialist/Windows 7

This three-day instructor-led course provides existing SQL Server database professionals with the knowledge

Updating your Database skills to Microsoft SQL Server 2012

Symantec Backup Exec (TM) 13 Installation Log

Microsoft Enterprise Search for IT Professionals Course 10802A; 3 Days, Instructor-led

Implementing Data Models and Reports with Microsoft SQL Server

AJAX SSL- Wizard Reference

Search Engines Chapter 2 Architecture Felix Naumann


Restoring Data with Database Snapshots

VirtualSchool Office365 Lizenzen zuweisen Feb 2013

Schöll MOC Installing and Configuring Windows Server 2012

DocAve 6 SDK and Management Shell

Schulbildung Otzbergschule in Otzberg Iranisch-Deutsche Schule in Teheran/Iran Albert-Einstein-Schule in Groß-Bieberau

Course 10978A Introduction to Azure for Developers

Microsoft Azure for IT Professionals 55065A; 3 days

ISO/IEC 27001:2013 Thema Änderungen der Kontrollen der ISO/IEC 27001:2013 im Vergleich zur Fassung aus 2005 Datum

CommVault Simpana 7.0 Software Suite. und ORACLE Momentaufnahme. Robert Romanski Channel SE

Oracle EM 12cc als Datenlieferant für ITAM/SAM Tools?

How to Back Up and Restore a Dynamics NAV 2015 Database Using SQL and PowerShell:

ADMINISTERING MICROSOFT SQL SERVER DATABASES

Designing and Deploying Messaging Solutions with Microsoft Exchange Server 2010 MOC 10233

MOC MICROSOFT WINDOWS SERVER 2008 Hs Inicio Fin Días Horario Planning and Implementing Windows Server may. 6-jun.

Administering Microsoft SQL Server Databases

Microsoft Administering a SQL Database Infrastructure

Developing Microsoft Azure Solutions 20532B; 5 Days, Instructor-led

ACTIVE MICROSOFT CERTIFICATIONS:

ID: Microsoft Certified Professional Transcript. Microsoft Certification Status. Microsoft Certified Trainer Certification History

How to Copy A SQL Database SQL Server Express (Making a History Company)

Intel vpro Technology Module for Microsoft* Windows PowerShell*

MS 10978A Introduction to Azure for Developers

Certificate SAP INTEGRATION CERTIFICATION

Course 20462C: Administering Microsoft SQL Server Databases

TBarCode.NET Barcodes in MS SQL Reporting Services

Administering Microsoft SQL Server Databases

Tutorial: How to Use SQL Server Management Studio from Home

Course 20764A: Administering a SQL Database Infrastructure

MOC DEVELOPING WINDOWS AZURE AND WEB SERVICES

Administering Microsoft SQL Server Databases

Open Text Social Media. Actual Status, Strategy and Roadmap

Microsoft Nano Server «Tuva» Rinon Belegu

Softwareprojekt: Mobile Development Einführung Objective-C. Miao Wang, Tinosch Ganjineh Freie Universität Berlin, Institut für Informatik

Course 10174B: Configuring and Administering Microsoft SharePoint 2010

Linux & Docker auf Azure

Implementing a Data Warehouse with Microsoft SQL Server 2012

VSTO 3.0 In Action mit Outlook Lars Keller netcreate OHG

OPAS Prerequisites. Prepared By: This document contains the prerequisites and requirements for setting up OPAS.

Enterprise Self Service Quick start Guide

10174: Configuring and Managing Microsoft SharePoint 2010

Upgrading Your Skills to MCSA Windows Server 2012

Introduction to Azure for Developers

This module provides an overview of service and cloud technologies using the Microsoft.NET Framework and the Windows Azure cloud.

PCSchool SQL Backup Tech Tip. SQL Backup Tech Tip. Created in version /9

Microsoft Training and Certification Guide. Current as of December 31, 2013

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

10978A: Introduction to Azure for Developers

Upgrading Your Skills to MCSA Windows Server 2012

Please contact Cyber and Technology Training at for registration and pricing information.

CP003 Azure SQL Database V12 updates and comparison with SQL Server

Microsoft SQLServer Restore / Redirected Restore Procedure

Microsoft Introduction to Azure for Developers

FritzConnection. Eine Python-Schnittstelle zur AVM FritzBox. FritzConnection pythoncamp 2013 Klaus Bremer

Windows Server und Windows Vista-Gruppenrichtlinien

"Charting the Course to Your Success!" MOC B Configuring and Administering Microsoft SharePoint Course Summary

LT Auditor Windows Assessment SP1 Installation & Configuration Guide

Administering Microsoft SQL Server Databases

LEARNING AGREEMENT FOR STUDIES

Die SharePoint-Welt für den erfahrenen.net- Entwickler. Fabian Moritz MVP Office SharePoint Server

Installation and Configuration in Microsoft Dynamics NAV 2013

Managing Enterprise Devices and Apps using System Center Configuration Manager

WINDOWS AZURE SQL DATA SYNC

Rainer Stropek time cockpit. NuGet

Windows Azure: What s new?

Automatizace Private Cloud. Petr Košec, Microsoft MVP, MCT, MCSE

Configuring and Administering Microsoft SharePoint 2010

Designing Database Solutions for Microsoft SQL Server 2012 MOC 20465

Transcription:

Powershell und SQL na wie geht das denn?

Holger Voges CCA,MCSE, MCDBA, MCT, MCITP DB Administrator / DB Developer, MCTIP Enterprise Administrator, MCSE Windows Server 2012 Netz-Weise Freundallee 13a 30173 Hannover www.netz-weise.de

SQL-Server Powershell Modul Microsoft Feature Pack: SQLSysClrTypes.msi ShareManagementObjects.msi PowerShellTools.msi PS:> Import-Module name sqlps

Invoke-Sqlcmd sqlcmd.exe auf Powershell Liefert Daten als Objekte zurück Invoke-Sqlcmd query select * from AdventureWorks2012.Person.Address ServerInstance.

Neu, nicht mit Perwoll geschaffen Add-SqlFirewallRule Get-SqlDatabase Get-SqlInstance Get-SqlSmartAdmin New-SqlBackupEncryptionOption Remove-SqlFirewallRule Set-SqlAuthenticationMode Set-SqlNetworkConfiguration Set-SqlSmartAdmin Start-SqlInstance Stop-SqlInstance Test-SqlSmartAdmin

Commandlets für Always on CommandType Name ModuleName ----------- ---- ---------- Add-SqlAvailabilityDatabase sqlps Add-SqlAvailabilityGroupListenerStaticIp sqlps Join-SqlAvailabilityGroup sqlps New-SqlAvailabilityGroup sqlps New-SqlAvailabilityGroupListener sqlps New-SqlAvailabilityReplica sqlps Remove-SqlAvailabilityDatabase sqlps Remove-SqlAvailabilityGroup sqlps Remove-SqlAvailabilityReplica sqlps Resume-SqlAvailabilityDatabase sqlps Set-SqlAvailabilityGroup sqlps Set-SqlAvailabilityGroupListener sqlps Set-SqlAvailabilityReplica sqlps Suspend-SqlAvailabilityDatabase sqlps Switch-SqlAvailabilityGroup sqlps Test-SqlAvailabilityGroup sqlps Test-SqlAvailabilityReplica sqlps Disable-SqlAlwaysOn sqlps Enable-SqlAlwaysOn sqlps

Weitere Commandlets CommandType Name ----------- ---- Add-SqlFirewallRule Backup-SqlDatabase Convert-UrnToPath cmdlet Decode-SqlName Encode-SqlName Get-SqlCredential Get-SqlDatabase Get-SqlInstance Get-SqlSmartAdmin Invoke-PolicyEvaluation Invoke-Sqlcmd New-SqlBackupEncryptionOption New-SqlCredential New-SqlHADREndpoint CommandType Name ----------- ---- Remove-SqlCredential Remove-SqlFirewallRule Restore-SqlDatabase Set-SqlAuthenticationMode Set-SqlCredential Set-SqlHADREndpoint Set-SqlNetworkConfiguration Set-SqlSmartAdmin Start-SqlInstance Stop-SqlInstance Test-SqlDatabaseReplicaState Test-SqlSmartAdmin

Sql Server Managed Backup für Azure cd SQLSERVER:\SQL\Computer\MyInstance $encryptionoption = New-SqlBackupEncryptionOption -EncryptionAlgorithm Aes128 -EncryptorType ServerCertificate -EncryptorName "MyBackupCert" Get-SqlSmartAdmin Set-SqlSmartAdmin BackupEnabled $True BackupRetentionPeriodInDays 10 - EncryptionOption $encryptionoption

Server Management Objects Grundlage für Powershell Wird von PSH automatisch geladen Stellt eine API zum SQL-Server dar Liefert jede Menge Diagnoseinformationen $instancename = SQL2012" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instancename

SQL-Server Powershell Provider SQLServer: SQL SQLPolicy SQLRegistration Utility DAC DataCollection IntegrationServices SQLAS

SQLPS aus dem Management Studio

SQL-Agent Jobs mit Powershell $RSService = "http://localhost/reportserver/reportservice2010.asmx?wsdl" $RSServiceProxy = New-WebServiceProxy -uri $RSService -class RS2 -Namespace ReportingWebservice -Credential Get-Credential $RSServiceProxy.ListSubscriptions("") $id = $RSServiceProxy.ListSubscriptions("") where Report -eq "Sales_Order_Detail_2008R2" select subscriptionid -ExpandProperty $RSServiceProxy.FireEvent("TimedSubscription",$id,"") Reports generieren mit dem Agent

SQL mit Powershell ausführen Invoke-sql startet SQL-Befehle Wenn sqlps nicht zur Verfügung steht, muß.net herhalten $ConnStr = "Server=SQLDB;Initial Catalog=Nwind;Integrated Security = True" $conn= New-Object System.Data.SQLClient.SQLConnection $conn.connectionstring = $ConnStr $Conn.Open() $command = New-Object System.Data.SqlClient.SqlCommand $command.connection = $conn $statement = "INSERT INTO log (runtime,errors) values ('$($endtime)',$($errors))" $command.commandtext = $Statement $command.executenonquery()

Weiterführende Informationen www.simpletalk.com www.netz-weise.de/weisheiten

Netz-Weise * Freundallee 13a * 30173 Hannover Bult www.netz-weise.de Ihr Anbieter für professionelle Schulungen