Making PowerShell Useful Real-Life Examples of Powershell in Action Slides available here - http://1drv.ms/1Lx7cxN
Thank you to our AWESOME sponsors!
Agenda 1 2 3 4 5 6 Who Why Where What How Finally Just so you know what is happening today a quick agenda Who What Why How Finally
Twitter: sqldbawithbeard Who am I? 1 Email: mrrobsewell@outlook.com Profile: Rob Sewell Twitter: sqldbawithbeard Blog: sqldbawithabeard.com Just to show you how to contact me – You don’t need any more than that
What is PowerShell? 2 According to MSDN Two-Faced Behind the Scenes It’s a Shell It’s a Scripting Language Click Here Behind the Scenes Replacing the GUI Ask what is Powershell and you will get a thousand different answers MSDN says It’s a Shell, everything you can do in CMD you can do in PS and you can use UNIX Aliasis too like ls rm etc but your outputs are .NET objects It’s a language so you can create your own tools Microsoft are using it and will continue to use it – It powers many GUIS and enables you to do things the GUI cannot in Exchange, Active Directory and especially in Azure There is no GUI -= Server Core is getting more popular and In the October 2009 issue of TechNet Magazine, Microsoft says, "It's safe to say that the single most important skill a Windows administrator will need in the coming years is proficiency with Windows PowerShell." Server Core Azure Paas Powering the GUI Remote Management
Why use PowerShell? 3 What I want to be doing What I end up doing Building New Shiny Things Exploring the best way to solve that ………. Concentrating on writing and testing that complex procedure/script Completing documentation* Answering the phone Answering Email Performing mundane repetitive tasks
WARNING – PowerShell is not the ONLY resource you should use Why use PowerShell? 3 AUTOMATE EVERYTHING I read a post by @SQLBrit The Best DBAs Automate everything I automate as much as is feasibly possible mostly through PowerShell Backups and restores through Dev/SAT/FAT/UAT/Live environments Daily Backup Checks, Drive Space Checks, Service Running Checks, File Space Checks, Failed Agent Job Checks, SQL Error Log Checks, DBCC Checks and more The Answer? WARNING – PowerShell is not the ONLY resource you should use Automate from wikipedia Automation is the use of machines, control systems and information technologies to optimize productivity in the production of goods and delivery of services
Why use PowerShell? 3 Disaster Recovery make repetitive tasks easier and less tedious. make complex tasks less complex by wrapping several commands together. automate tasks and reduce the risk of human error. Disaster Recovery
My Functions Why use PowerShell? 3 Find A Database Check Disk Space Search All SQL Error Logs Find A Database make repetitive tasks easier and less tedious. make complex tasks less complex by wrapping several commands together. Show Last Database Backup Show SQL Services make repetitive tasks easier and less tedious. Write Functions that work in your environment to answer your questions SQL Error Log Show Processes On Server Show Databases Create Windows Account Add Users To Role Show A Users Permissions automate tasks and reduce the risk of human error. Show Server Permissions Create SQL Account Show Windows Event Log Check A Users Logins Drop A User Check Disk Space Show Last Backups On Server Show Automatic Start Services
How – Repetitive Tasks 4 Demo
How 4 Use CTRL + J How can I learn the syntax Can I make that easier? That looks Difficult How will I learn that? How can I learn the syntax Can I make that easier? Use CTRL + J
I can write scripts and functions How 4 I can write scripts and functions But I work in a Team Do I have to teach them? Can you make it easier
I can write scripts and functions How 4 I can write scripts and functions ? Demo Can you make it easier
Or maybe for your Disaster Recovery Run Book How – Complex Tasks 4 The Service needs a Database which uses Availability Groups for HADR The System that Creates the data cannot be exposed externally Or maybe for your Disaster Recovery Run Book There is a scheduled window where data refreshes are required Errors introduced by manual refreshes cost money
How – Complex Tasks 4 The Service needs a Database which uses Availability Groups for HADR The System that Creates the data cannot be exposed externally Demo There is a scheduled window where data refreshes are required Errors introduced by manual refreshes cost money
Where Can I Find Out More? 5 Windows PowerShell Reference on MSDN http://powershell.org/ Hey Scripting Guy Powershell Magazine Script Center Pluralsight Laerte Junior Simple Talk DBA Stack Exchange And Many More!! (I have missed loads)
Hopefully 6 You have learnt You can use Powershell How to create a function CTRL + J How to pass on Knowledge to your team How to set up more complex scripts Where to go for more help
Questions 6
Twitter: sqldbawithbeard Contact Me Email: mrrobsewell@outlook.com Profile: Rob Sewell Twitter: sqldbawithbeard Blog: sqldbawithabeard.com Just to show you how to contact me – You don’t need any more than that SQL SATURDAY EXETER 12th March 2016 Open for Registrations and Session Submissions Come and Ask me if you have Questions