Download presentation
Presentation is loading. Please wait.
Published byAlexia Davis Modified over 6 years ago
1
Getting Started with PowerShell Basics for SQL Server Admin
Michael Wharton web site: ‘ Blog: ‘
2
7 th About: Michael Wharton (PMO Consultant) Microsoft
30+ EPM Deployments EPM Migrations Trained Project Manager PMO Automations and Monitoring Fundamentals of Scheduling Microsoft MVP | MCT | MCTS | MCP+44 Technical Reviewer Missing Manual: Project 2010 and Project 2013 Project Management using MS Project 2013 Forecast Scheduling 2013 Writing Book: Monitoring and Controlling the PMO 7 th My passion real passion is automating and monitoring Project Server My second passion is maintaining good Field Notes!! Using PowerShell Field Notes Windows SQL Server SharePoint Project Server Consistency with Deployments. Comic Books Hardware Hacking Robots Walking Wharton Computer Consulting since 1997 PowerShell Field Notes MyProjectExpert.com © 2007 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.
3
Comics, Sci-Fi, Net Runner
4
Love Hardware
6
Learning Objective Get You Started with Using PS>
And using it with SQL Server Get Excited About PowerShell! Open Your Eyes to the Power! Get you ready for the Future! Provide you more Job Security MAKE YOUR OWN TOOLS Get Excited About Using PowerShell ** It’s just too cool Open Your Eyes to Automating SQL Admin ** Automate process and procedures ** Make yourself valuable, repeatable and up-to-date **
7
Survey Who are You? Currently Using PowerShell?
SQL admins SQL developers IT Professional (network) Software Developers Currently Using PowerShell? Currently using PowerShell Remoting
8
What can you do with PowerShell?
Repeated Tasks Automated Processes Get info from multiple pc/server Manage multiple pc/servers Manage anything based on .NET Required for some tasks (exchange) Repeated Task Managing users with of 10 or 20 clicks thru GUI (adding users to AD ) Clean up of deleted users Building new environments Standard installations Automated Process Generate reports Retrieve and pull data Get Information from PC/Multiple server Checking security updates and patches Pulling data and generating reports Managing Multiple pc/Servers 1) Checking that software is loaded or not loaded SQL Admin with PowerShell Using PowerShell Remoting to pull data from one or more SQL servers Performing SQL Maintenance on one or more SQL Servers If this doesn’t get you interested. Then this may not be the session for you. Unless you just want to learn some PowerShell REMOTE INTO
9
Making your own SQL Power Tools!
Active Directory – Bulk Add, fix duplicate, save to CSV, computer accounts, domains, monitoring, user accounts Applications Backup and Restore Exchange Logs and Monitoring Networks Office Operating System Security SharePoint Storage
10
PS> can manage Active Directory Applications Backup and Restore
Exchange Logs and Monitoring Networks Office Operating System Security SharePoint Storage SQL Server Azure Linux CSOM Just about anything!!! Active Directory – Bulk Add, fix duplicate, save to CSV, computer accounts, domains, monitoring, user accounts Applications Backup and Restore Exchange Logs and Monitoring Networks Office Operating System Security SharePoint Storage
11
TechNet and Github PowerShell Gallery
Databases ActiveX Data Objects 36 MySQL (4) Oracle (9) SQL Server (1064) *** Sybase (2) Repeated Task Managing users with of 10 or 20 clicks thru GUI (adding users to AD ) Clean up of deleted users Building new environments Standard installations Automated Process Generate reports Retrieve and pull data Get Information from PC/Multiple server Checking security updates and patches Pulling data and generating reports Managing Multiple pc/Servers 1) Checking that software is loaded or not loaded SQL Admin with PowerShell Using PowerShell Remoting to pull data from one or more SQL servers Performing SQL Maintenance on one or more SQL Servers If this doesn’t get you interested. Then this may not be the session for you. Unless you just want to learn some PowerShell REMOTE INTO
12
PowerShell Gallery https://www.powershellgallery.com/ xSQLServer (DSC)
Deployment and configuration cSQLconfig One time configuration Repeated Task Managing users with of 10 or 20 clicks thru GUI (adding users to AD ) Clean up of deleted users Building new environments Standard installations Automated Process Generate reports Retrieve and pull data Get Information from PC/Multiple server Checking security updates and patches Pulling data and generating reports Managing Multiple pc/Servers 1) Checking that software is loaded or not loaded SQL Admin with PowerShell Using PowerShell Remoting to pull data from one or more SQL servers Performing SQL Maintenance on one or more SQL Servers If this doesn’t get you interested. Then this may not be the session for you. Unless you just want to learn some PowerShell REMOTE INTO
13
Why PowerShell such a Big Deal?
Windows Linux GUI Based Document Based No Piping Piping Limited Functionality Unlimited Functionality Coding to build new commands Build new commands PowerShell takes on best features of Linux No GUI Document Based Piping Extends the .NET Framework Unlimited Functionality Operating Systems Windows 7 Windows 8 and 8.1 Windows 10 Ubantu Windows XP Linux Macintosh Android Windows XP, Vista, 98, 95, 3.1 Chrome REMOTE INTO
14
Microsoft Future GUI on server Mostly cmdlets
Improve Security Smaller footprint Push to the cloud PS Managed DSC (Desire State Configuration) Nano Server Containers Enjoy using Project Have fun working with… make it work for you.. Not against you When I first started using --- then I started going … this sucks, this sucks and now back to enjoying Understand how what is going on Key Engineers Jeffery Hicks / Don Jones / Jeffrey P Snover Snover Monad Manifesto Scriptable shell Command Line Interface -- Admin want GUI Push back on GUI “Services for UNIX” -- almost work but not pure Core Linix vs Windows is API --Linix is a document oriented --edit a file Windows is API only works with GUI – work CLIs and WMIC -- IIS is one of the only WMIC --- lot’s of code required to produce results Windows Management Interface Command (WMIC) Single script for each time – everything had to be test Very difficult to write command lines Piping – A | B | C Monad Manifesto Monad – PowerShell V1 Windows Server Optional PowerShell V2 Windows 2008 R2 Many tools and real function PowerShell V3 Windows 2012 PowerShell V4 Windows R2 PowerShell V5
15
What can PS> Do?
16
SQL Admin Functions – Managing Users Checking Backups
Checking Error and Event Logs Creating Databases Running DBCC Managing and Checking Security Managing and Checking Policy Checking Hot Fixes and SP Starting/Stopping Services Discovering Services Listing SQL configurations Changing SQL configurations Creating Databases Running DBCC Managing Security Managing Policy
17
Automate – Startup Programs, Process and Web sites
18
Automated – Check Service status
19
Automate – Search Logs Files
20
Automate – Search Events Logs
21
Automate – Ping sites
22
Follow Along on Laptop
23
How to Start PS> ? Start / All Programs / Accessories / Windows PowerShell Two GUI layouts SQL Management has PowerShell Newer versions of PowerShell can be installed. Newer versions of .NET Framework are installed Other ways is putting short-cuts on task bar. Use SEARCH to Find
24
PowerShell PS> prompt
PowerShell Prompt Basic interface – much like does prompt The early version had a few more features than the ISE version mainly the ability to log your session
25
PowerShell ISE Purchase tools that provide more features from
26
Starting PS> in SQL Management Studio
27
Learning PowerShell Learn How To Learn (Discovery)
Get-Help and Update-Help Get-Command and Show-Command Get-Member and Sort-Object Get PS-Drive Get-h
28
PowerShell Fundamentals 1/2
Essential Commands - Get-Help To Execute Script Setting Security Policy Functions Variables POWERSHELL.ORG Arrays Constants Creating Objects Writing to Console Capture User Input Passing Command Line Arguments PowerShell.org – documents Windows PowerShell – EN.PDF Essential Commands - Get-Help To Execute Script Setting Security Policy Functions Variables Arrays Constants Creating Objects Writing to Console Capture User Input Passing Command Line Arguments
29
PowerShell Fundamentals 2/2
Do While Loop Do Until Loop For Loop For Each Loop If Statement Switch Statement POWERSHELL.ORG Reading from a File Writing to a Simple File Writing to a HTML File Writing to a CSV File Miscellaneous Do While Loop Do Until Loop For Loop For Each Loop If Statement Switch Statement Reading from a File Writing to a Simple File Writing to a HTML File Writing to a CSV File Miscellaneous Piping, Continuation, Add-in
30
Get-Help
31
Get-Help Get-Service
32
Get-Help Get-Service -Examples
33
Get-Service | Get-Member
34
Get-Service
35
cmd> | cmd> | cmd (Piping)
36
PS> Comments
37
PS SQL Server Basics Demo
Get-Help SQL Get-Help SQL-InvokeSQL Demo Script – using PowerShell Adding In and Library Remoting
38
Get-Help SQL
39
Get-Command SQL 1/2
40
Get-Command SQL 2/2
41
Invoke-SQLcmd
42
SMO
43
Get SQL Configuration
44
SQL Server Remoting Demo Script – using PowerShell
Adding In and Library Remoting
45
Remoting: How does it Work
Part of the WinRM architecture Uses the WSMan HTTP protocol Connects with the server’s WinRM service WSMPROHOST.EXT hosts PowerShell for Remoting session
46
Remoting: How Does it Work
Endpo I nt WSMAN HTTP PowerShell wsmprovhost CLIENT SERVER
47
Remoting: Setup Use Enable-PSRemoting cmdlet to enable remoting on servers In a domain: Enable Allow Automatic Configuration of Listeners policy In path Compute Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRm) \WinRm serice Get-PSSessionConfiguration Shows the endpoints Use Enable-Psremoting to enable remoting
48
Learned PowerShell Fundamentals Great Tool for SQL Administration
Skill for any IT Pro PS> is Microsoft Direction Automation SQL Remoting Building SQL Tools Enjoy using Project Have fun working with… make it work for you.. Not against you When I first started using --- then I started going … this sucks, this sucks and now back to enjoying Understand how what is going on
49
Reference PowerShell.org Windows PowerShell Cookbook - Lee Holmes
Windows PowerShell for Developers – Douglas Finke PowerShell for SharePoint 2013 – Steven Mann Windows Server 2012 R2 Administrator Cookbook – Jordan Krause Secrets of PowerShell Remoting – Don Jones and Dr. Tobias Weltner Use PowerShell Remoting to Manager SQL Server Efficiently Learn Windows PowerShell 3 in a month of Lunches Second Edition – Don Jones, Jeffery Hicks SQL Server 2012 with PowerShell V3 Cookbook by Donabel Santos Reference Material PowerShell.org Windows PowerShell Cookbook - Lee Holmes Windows PowerShell for Developers – Douglas Finke PowerShell for SharePoint 2013 – Steven Mann Windows Server 2012 R2 Administrator Cookbook – Jordan Krause Secrets of PowerShell Remoting – Don Jones and Dr. Tobias Weltner Use PowerShell Remoting to Manager SQL Server Efficiently Learn Windows PowerShell 3 in a month of Lunches Second Edition – Don Jones, Jeffery Hicks SQL Server 2012 with PowerShell V3 CookBook by Donabel Santos Use PowerShell Remoting to Manager SQL Server Efficiently powershell-remoting-manage-sql-servers-efficiently Lean Windows PowerShell 3 in a month of Lunches Second Edition – Don Jones, Jeffery Hicks Understanding and Using PowerShell Support in SQL Server us/library/dd aspx
51
PowerShell Games! General Game Rules
Informal to promote fun and learning Present a Problem Start timer First person to solve – Note time and give 5 more minutes to group Awards Overall Winner – First to solve Problem using PowerShell Fewest Lines to solve winner Most Lines to solve winner Panel of experts picks best solution Discussion on how user approached Each winner describes approach Reference Material PowerShell.org Windows PowerShell Cookbook - Lee Holmes Windows PowerShell for Developers – Douglas Finke PowerShell for SharePoint 2013 – Steven Mann Windows Server 2012 R2 Administrator Cookbook – Jordan Krause Secrets of PowerShell Remoting – Don Jones and Dr. Tobias Weltner Use PowerShell Remoting to Manager SQL Server Efficiently Learn Windows PowerShell 3 in a month of Lunches Second Edition – Don Jones, Jeffery Hicks SQL Server 2012 with PowerShell V3 CookBook by Donabel Santos Use PowerShell Remoting to Manager SQL Server Efficiently powershell-remoting-manage-sql-servers-efficiently Lean Windows PowerShell 3 in a month of Lunches Second Edition – Don Jones, Jeffery Hicks Understanding and Using PowerShell Support in SQL Server us/library/dd aspx
52
Future PowerShell Meetings
Meetup Raleigh PowerShell CPSUG Charlotte PowerShell User Group PowerShell Summit Redmond 2016 Oct 10, 2015 Raleigh SQL Saturday Beginners Guide to PowerShell and SQL Server Oct 17, 2015 Charlotte SQL Saturday Check Meetups.com and local user groups Sept 27/ Triad Developer Guild Beginner Guide to PowerShell and SharePoint Sept 3, 2015 Charlotte PowerShell Users Group Using PowerShell Installing and Configuring SharePoint / Project Server Sept 19, 2015` Charlotte Area SharePoint User Group Beginners Guide to PowerShell and SharePoint Sept 25, 2015 DerbyCon Beginners Guide to PowerShell and Hacking Oct 10, 2015 Raleigh SQL Saturday Beginners Guide to PowerShell and SQL Server Oct 17, 2015 Charlotte SQL Saturday
53
PowerShell Field Notes
11/8/2018 8:46 PM Questions and Answers Michael Wharton 30+ EPM Deployments 10+ EPM Migrations 1000+ Trained Project Manager PMO Automations and Monitoring Fundamentals of Scheduling Microsoft MVP | MCT | MCTS | MCP+44 Technical Reviewer Missing Manual: Project 2010 and Project 2013 Project Management using MS Project 2013 Forecast Scheduling 2013 (in process) Writing Book: Monitoring and Controlling the PMO My passion real passion is automating and monitoring Comic Books Hardware Hacking Robots Walking Wharton Computer Consulting since 1997 PowerShell Field Notes MyProjectExpert.com © 2007 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.
54
Michael Wharton, MVP
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.