Presentation is loading. Please wait.

Presentation is loading. Please wait.

EXPLORING THE SQL POWERSHELL MODULE

Similar presentations


Presentation on theme: "EXPLORING THE SQL POWERSHELL MODULE"— Presentation transcript:

1 EXPLORING THE SQL POWERSHELL MODULE

2 Mike Fal

3 What is SqlServer (SQLPS)?
Get-Agenda What is SqlServer (SQLPS)? The Provider Cmdlets/Functions Practical Use

4 Don’t focus on the code, focus on the concepts.
Don’t Panic! Don’t focus on the code, focus on the concepts. Ask questions!

5 In the beginning…

6 SQLPS The Basics Powershell module for SQL Server
Includes cmdlets and the provider SQL Server 2012 or greater Powershell 2.0 or greater Import-Module SQLPS

7 SqlServer SqlServer Introduced with SSMS July 2016 update!
Includes everything from SQLPS along with fixes Not compatible with SQLPS! Import-Module SqlServer

8 Installation Not installed specifically previous to SQL 2016 SP1
Included anytime you install ANY SQL Server component SQLPS Installation Path: C:\Program Files (x86) \Microsoft SQL Server \130\Tools\PowerShell\Modules SqlServer Installation Path C:\Program Files\WindowsPowerShell\Modules

9 Installation with SSMS 17/SQL 2016
PowerShell Gallery ( Install-Module SqlServer (PowerShell 5.0+)

10 SQL Server Management Objects (SMO)
Built on the SMO SQLPS\SqlServer SQL Server Management Objects (SMO) .Net Library requires .Net 2.0

11 What Makes It Work? SMO ASSEMBLIES
Microsoft.SqlServer.Management.Common Microsoft.SqlServer.SqlEnum Microsoft.SqlServer.Smo Microsoft.SqlServer.RegSvrEnum Microsoft.SqlServer.Dmf Microsoft.SqlServer.WmiEnum Microsoft.SqlServer.Instapi Microsoft.SqlServer.ServiceBrokerEnum Microsoft.SqlServer.SqlWmiManagement Microsoft.SqlServer.ConnectionInfoExtended Microsoft.SqlServer.ConnectionInfo Microsoft.SqlServer.Management.Collector Microsoft.SqlServer.SmoExtended Microsoft.SqlServer.Management.CollectorEnum Microsoft.SqlServer.SqlTDiagM Microsoft.SqlServer.Management.Dac Microsoft.SqlServer.SString Microsoft.SqlServer.Management.DacEnum Microsoft.SqlServer.Management.RegisteredServers Microsoft.SqlServer.Management.Utility Microsoft.SqlServer.Management.Sdk.Sfc

12 DEMO!

13 SQL Server and the File System

14 Windows Components as Drives Explore/Use like a FileSystem
Providers Windows Components as Drives Get-PSDrive Explore/Use like a FileSystem

15 SQL Server Provider PS SQLSERVER:\sql\localhost\default Provider
Folder Host/Server Instance

16 DEMO!

17 Tab completion and Intellisense
Gotchas Timeouts! Tab completion and Intellisense Contextual behavior

18 SQLPS Cmdlets Verb-Noun

19 Cmdlet Overview

20 Cmdlets: General Purpose
Add-SqlLogin Get-SqlDatabase Get-SqlInstance *** Get-SqlErrorLog Invoke-SqlCmd Read-SqlTableData/Read-SqlViewData Write-SqlTableData Add-RoleMember Invoke-Sqlcmd Add-SqlLogin Invoke-SqlVulnerabilityAssessmentScan ConvertFrom-EncodedSqlName New-SqlCredential ConvertTo-EncodedSqlName New-SqlVulnerabilityAssessmentBaseline Convert-UrnToPath New-SqlVulnerabilityAssessmentBaselineSet Export-SqlVulnerabilityAssessmentBaselineSet Read-SqlTableData Export-SqlVulnerabilityAssessmentScan Read-SqlViewData Get-SqlCredential Remove-RoleMember Get-SqlDatabase Remove-SqlCredential Get-SqlErrorLog Remove-SqlLogin Get-SqlInstance Save-SqlMigrationReport Get-SqlLogin Set-SqlCredential Import-SqlVulnerabilityAssessmentBaselineSet Set-SqlErrorLog Invoke-PolicyEvaluation

21 Cmdlets: SQL Agent Management
Get-SqlAgent Get-SqlAgentJob Get-SqlAgentJobHistory Get-SqlAgentJobSchedule Get-SqlAgentJobStep Get-SqlAgentSchedule

22 Cmdlets: Backup and Restore
Backup-SqlDatabase Restore-SqlDatabase New-SqlBackupEncryptionOption Get-SqlSmartAdmin Set-SqlSmartAdmin Test-SqlSmartAdmin Standard Backup and Restore operations SqlSmartAdmin cmdlets for Azure Managed Backups

23 Cloud Management Add-SqlFirewallRule Remove-SqlFirewallRule
Get-SqlInstance *** Set-SqlAuthenticationMode Set-SqlNetworkConfiguration Start-SqlInstance Stop-SqlInstance These cmdlets all require the Cloud Adapter Service This has been fixed, but if you use the old version… These do the same as Start-Service and Stop-Service

24 Cmdlets: Advanced Cmdlets
Availability Group Management AlwaysEncrypted Management SSAS Management (merged from SQLAS)

25 DEMO!

26 Poorly Documented (Changing!)
Gotchas Poorly Documented (Changing!) Unexpected behavior

27 So now what?

28 DEMO!

29 What is the SqlServer/SQLPS Module? How do we use it?
Wrapping up! What is the SqlServer/SQLPS Module? How do we use it? The Provider, what is that all about? What kind of cmdlets (functions) are there? How do I use this darn thing, anyway?

30 Questions mike@mikefal.net www.mikefal.net @Mike_Fal


Download ppt "EXPLORING THE SQL POWERSHELL MODULE"

Similar presentations


Ads by Google