
- 186 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
eBook - ePub
PowerShell for SQL Server Essentials
Tools to learn more effectively

Saving Books

Keyword Search

Annotating Text

Listen to it instead
Information
PowerShell for SQL Server Essentials
Table of Contents
PowerShell for SQL Server Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Instant updates on new Packt books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with PowerShell
A brief history of PowerShell
The PowerShell environment
The PowerShell console
The PowerShell ISE
Running PowerShell as an administrator
The execution policy
PowerShell versions
PowerShell cmdlets
Cmdlet naming convention
Cmdlet parameters
Cmdlet aliases
PowerShell providers
Snap-ins and modules
PowerShell Pipeline
Scripting basics
Running PowerShell scripts
Getting help
Getting help from other cmdlets
Summary
2. Using PowerShell with SQL Server
SQL Server via PowerShell
Mini-shell (or the sqlps utility)
The SQLPS module
SQL Server snap-ins
SQL Server assemblies
SQL Server-specific cmdlets
SQL Server Management Objects
Creating SMO objects
Summary
3. Profiling and Configuring SQL Server
Current server resources
Getting processor (CPU) information
Checking server memory
Checking disk space
Checking network settings
Hotfixes and service packs
Current SQL Server instances
Services and service accounts
SQL Server error logs
Current instance configuration
Changing configurations
Start or stop services
Changing a service account
Changing instance settings
Summary
4. Basic SQL Server Administration
Listing databases and tables
Listing database files and filegroups
Adding files and filegroups
Listing the processes
Checking enabled features
Scripting database objects
Attaching and detaching databases
Detaching databases
Backing up and restoring databases
Backing up
Restoring
Reorganizing or rebuilding indexes
Managing logins, users, and permissions
Permissions
Adding a login
Adding database users
Policies
Managing jobs
Summary
5. Querying SQL Server with PowerShell
To PowerShell or not to PowerShell
Sending queries to SQL Server
SQL Server Management Objects
The Invoke-Sqlcmd cmdlet
ADO.NET
The Invoke-Expression cmdlet
Sending simple queries to SQL Server – different variations
Fixing orphaned users
Getting fragmentation data
Backing up and restoring databases
Exporting data using bcp
Summary
6. Monitoring and Automating SQL Server
Getting to know helpful cmdlets
The Send-MailMessage cmdlet
The ConvertTo-Html cmdlet
The Export-Csv cmdlet
The Write-EventLog cmdlet
Additional cmdlets
Scheduling PowerShell scripts
Checking logs
Monitoring failed jobs
Alerting on disk space usage
Logging blocked processes
Getting performance metrics
Summary
A. Implementing Reusability with Functions and Modules
Functions
Simple functions
Advanced functions
Best practices
Modules
Script modules
Summary
Index
PowerShell for SQL Server Essentials
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2015
Production reference: 1200215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-149-2
www.packtpub.com
2323__perlego__chapter_divider...Table of contents
- PowerShell for SQL Server Essentials
Frequently asked questions
Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access PowerShell for SQL Server Essentials by Donabel Santos in PDF and/or ePUB format, as well as other popular books in Computer Science & Entreprise Applications. We have over one million books available in our catalogue for you to explore.