Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PowerShell for SQL Server Essentials

You're reading from   PowerShell for SQL Server Essentials Manage and monitor SQL Server administration and application deployment with PowerShell

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher Packt
ISBN-13 9781784391492
Length 186 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Donabel Santos Donabel Santos
Author Profile Icon Donabel Santos
Donabel Santos
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Started with PowerShell FREE CHAPTER 2. Using PowerShell with SQL Server 3. Profiling and Configuring SQL Server 4. Basic SQL Server Administration 5. Querying SQL Server with PowerShell 6. Monitoring and Automating SQL Server A. Implementing Reusability with Functions and Modules Index

PowerShell providers

Simply put, a PowerShell provider provides a way for PowerShell to access a data store. To get a visual of a provider, think of the file system. The file system is a data store that contains information about files and folders and their properties. We can access the file system via the Command Prompt, PowerShell console, or Windows Explorer. Now try to apply this concept to another data store, for example, SQL Server. Imagine that you can navigate through the objects of SQL Server just the way you navigate your file system.

Learning about providers is important because this allows you to extend what you can do with PowerShell. To list the current providers in your system, use the Get-PSProvider cmdlet:

PowerShell providers

What you see in the preceding screenshot are the default available providers that come with PowerShell v4 on a Windows Server 2012 R2 Standard server. A lot of the providers are accessed using what is called drives. To list the current drives, you can use Get-PSDrive:

PowerShell providers

In a file system, if you wanted to change drives, you can use the cd command, which is an alias for Set-Location:

C:\> cd J:\

To navigate to a different provider, you can use the same concept. For example, if you want to navigate the HKLM registry hive (which stands for HKEY_LOCAL_MACHINE), you can use the following command lines:

C:\> cd HKLM:
HKLM:\>

To work with items in PSDrive, Microsoft has provided a number of Item cmdlets that are generic enough to perform the task regardless of which drive you are in. To get a list of these cmdlets, you can type Get-Command *Item*. For example, if you are using a file system, you can use the New-Item cmdlet to create a new folder or file. If you are in the registry, it will create a new registry entry.

The recent releases of Microsoft products come with their own PowerShell providers, which you can readily use. You can also create your own providers if you prefer.

Note

MSDN has some documentation on how you can create your own provider available at http://msdn.microsoft.com/en-us/library/ee126192(v=vs.85).aspx. There are even tutorials on how to create providers for non-Microsoft data stores. For example, the version control system Git by @manojlds is available at http://stacktoheap.com/blog/2012/12/01/writing-a-git-provider-for-windows-powershell-part-1/.

You have been reading a chapter from
PowerShell for SQL Server Essentials
Published in: Feb 2015
Publisher: Packt
ISBN-13: 9781784391492
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image