SlideShare a Scribd company logo
1 of 13
Download to read offline
Practical PowerShell
For The Busy DBA
Eric Cobb
http://www.sqlnuggets.com
11/19/2020
About Me
Microsoft Certified Trainer (MCT)
MCSE: Data Management and Analytics
MCSE: Data Platform
1999-2013: “Webmaster“, Programmer, Developer
2014+: SQL Server Database Administrator
GitHub: https://github.com/ericcobb
Blog: http://www.sqlnuggets.com
Twitter: @sqlnugg, @cfgears
About dbatools
Chrissy LeMaire, Creator
SQL Server & PowerShell MVP
SQL Server DBA with over 20 years of experience
As of today, dbatools has over 140 contributors on github and over 1700
users in the Slack channel
https://dbatools.io/team/
About dbatools
• Initially started out as a SQL Server migration tool
and has been around since 2014
• Over 500 SQL Server best practice, administration,
development, and migration commands
• https://dbatools.io/commands/
About dbatools
What Can It Do?
• Backup & Restore databases
• DBCC CHECKDB
• Mail and logging
• First Responder Kit
• sp_whoisactive
• Set Startup Params (Trace Flags)
• Availability Groups
• Check Drive Space
• Login and User Management
• SQL Agent
• sp_configure
• Glenn Berry’s Diagnostic Queries
• Install Ola Hallengren’s scripts
• Set Server Power Plan
• Run T-SQL Statements
• Set MAXDOP, Max Mem, Recovery
Things To Know
• You don't have to know how to program in
PowerShell
– You just have to learn to call the commands
• EXEC sp_Blitz @IgnorePrioritiesAbove = 50
• EXEC sp_WhoIsActive @get_plans = 1,@get_task_info = 2
• EXEC IndexOptimize @Databases = 'USER_DATABASES'
• Backup-DbaDatabase -SqlInstance 'Srvr1'-Database
'DbName’
• 723 lines of PowerShell code you didn’t have to write
Things To Know
• You don’t have to install dbatools on every server
– Only the client machine executing the commands needs
dbatools installed
– Can connect to all versions of SQL Server from SQL 2000
up, including Azure SQL Database and Azure Managed
Instances
Things To Know
• How to install dbatools
– Install-Module dbatools
– Detailed tutorial: https://dbatools.io/soup2nutz/
Things To Know
• What IDE to use?
– PowerShell ISE
– Visual Studio Code
– Idera PowerShell Plus
– Notepad
Things To Know
• Credentials
– By default, all SQL-based commands will login to SQL
Server using Windows Authentication
– To use alternative credentials, including SQL Logins or
alternative Windows credentials, use the –SqlCredential
parameter
Things To Know
• Pipeline
– Use the pipe character to string together a series of
PowerShell cmdlets
– Each pipeline operator sends the results of the preceding
command to the next command
– Command-1 | Command-2 | Command-3
– Get-Service 'MSSQLSERVER' | Stop-Service
Things To Know
• What if?
– dbatools has a –whatif parameter that will show you
what would happen if you run the command, without
actually running it
– “If this switch is enabled, no actions are performed but
informational messages will be displayed that explain
what would happen if the command were to run.”
Demo Time!

More Related Content

More from IDERA Software

Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
Idera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian FlugIdera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian Flug
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian FlugIDERA Software
 
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...IDERA Software
 
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021:  Managing Digital Transformation on a Budget by Bert ScalzoIdera live 2021:  Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021: Managing Digital Transformation on a Budget by Bert ScalzoIDERA Software
 
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...IDERA Software
 
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...IDERA Software
 
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...IDERA Software
 
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021:  Performance Tuning Azure SQL Database by Monica RathbunIdera live 2021:  Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021: Performance Tuning Azure SQL Database by Monica RathbunIDERA Software
 
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERAGeek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERAIDERA Software
 
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...IDERA Software
 
Benefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERABenefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERAIDERA Software
 
Achieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERAAchieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERAIDERA Software
 
Benefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERABenefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERAIDERA Software
 
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERABe Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERAIDERA Software
 
Advanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERAAdvanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERAIDERA Software
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarIDERA Software
 
Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...
Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...
Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...IDERA Software
 
Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...
Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...
Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...IDERA Software
 
Geek Sync | How to Think Like the SQL ServerEngine - Brent Ozar
Geek Sync | How to Think Like the SQL ServerEngine - Brent OzarGeek Sync | How to Think Like the SQL ServerEngine - Brent Ozar
Geek Sync | How to Think Like the SQL ServerEngine - Brent OzarIDERA Software
 
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAGeek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAIDERA Software
 
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...IDERA Software
 

More from IDERA Software (20)

Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
Idera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian FlugIdera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian Flug
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
 
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
 
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021:  Managing Digital Transformation on a Budget by Bert ScalzoIdera live 2021:  Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
 
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
 
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
 
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
 
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021:  Performance Tuning Azure SQL Database by Monica RathbunIdera live 2021:  Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
 
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERAGeek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
 
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
 
Benefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERABenefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERA
 
Achieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERAAchieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERA
 
Benefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERABenefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERA
 
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERABe Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
 
Advanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERAAdvanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERA
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
 
Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...
Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...
Geek Sync | Performance Tuning: Getting the Biggest Bang for Your Buck - Moni...
 
Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...
Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...
Geek Sync | Meeting Security Benchmarks and Compliance with Microsoft SQL Ser...
 
Geek Sync | How to Think Like the SQL ServerEngine - Brent Ozar
Geek Sync | How to Think Like the SQL ServerEngine - Brent OzarGeek Sync | How to Think Like the SQL ServerEngine - Brent Ozar
Geek Sync | How to Think Like the SQL ServerEngine - Brent Ozar
 
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAGeek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
 
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Geek Sync | Practical PowerShell For The Busy DBA

  • 1. Practical PowerShell For The Busy DBA Eric Cobb http://www.sqlnuggets.com 11/19/2020
  • 2. About Me Microsoft Certified Trainer (MCT) MCSE: Data Management and Analytics MCSE: Data Platform 1999-2013: “Webmaster“, Programmer, Developer 2014+: SQL Server Database Administrator GitHub: https://github.com/ericcobb Blog: http://www.sqlnuggets.com Twitter: @sqlnugg, @cfgears
  • 3. About dbatools Chrissy LeMaire, Creator SQL Server & PowerShell MVP SQL Server DBA with over 20 years of experience As of today, dbatools has over 140 contributors on github and over 1700 users in the Slack channel https://dbatools.io/team/
  • 4. About dbatools • Initially started out as a SQL Server migration tool and has been around since 2014 • Over 500 SQL Server best practice, administration, development, and migration commands • https://dbatools.io/commands/
  • 5. About dbatools What Can It Do? • Backup & Restore databases • DBCC CHECKDB • Mail and logging • First Responder Kit • sp_whoisactive • Set Startup Params (Trace Flags) • Availability Groups • Check Drive Space • Login and User Management • SQL Agent • sp_configure • Glenn Berry’s Diagnostic Queries • Install Ola Hallengren’s scripts • Set Server Power Plan • Run T-SQL Statements • Set MAXDOP, Max Mem, Recovery
  • 6. Things To Know • You don't have to know how to program in PowerShell – You just have to learn to call the commands • EXEC sp_Blitz @IgnorePrioritiesAbove = 50 • EXEC sp_WhoIsActive @get_plans = 1,@get_task_info = 2 • EXEC IndexOptimize @Databases = 'USER_DATABASES' • Backup-DbaDatabase -SqlInstance 'Srvr1'-Database 'DbName’ • 723 lines of PowerShell code you didn’t have to write
  • 7. Things To Know • You don’t have to install dbatools on every server – Only the client machine executing the commands needs dbatools installed – Can connect to all versions of SQL Server from SQL 2000 up, including Azure SQL Database and Azure Managed Instances
  • 8. Things To Know • How to install dbatools – Install-Module dbatools – Detailed tutorial: https://dbatools.io/soup2nutz/
  • 9. Things To Know • What IDE to use? – PowerShell ISE – Visual Studio Code – Idera PowerShell Plus – Notepad
  • 10. Things To Know • Credentials – By default, all SQL-based commands will login to SQL Server using Windows Authentication – To use alternative credentials, including SQL Logins or alternative Windows credentials, use the –SqlCredential parameter
  • 11. Things To Know • Pipeline – Use the pipe character to string together a series of PowerShell cmdlets – Each pipeline operator sends the results of the preceding command to the next command – Command-1 | Command-2 | Command-3 – Get-Service 'MSSQLSERVER' | Stop-Service
  • 12. Things To Know • What if? – dbatools has a –whatif parameter that will show you what would happen if you run the command, without actually running it – “If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.”