- PowerShell for SQL Server Essentials
- Donabel Santos
- 377字
- 2021-07-23 20:32:25
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:

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
:

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/.
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- ExtGWT Rich Internet Application Cookbook
- Java系統分析與架構設計
- AIRAndroid應用開發實戰
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- MATLAB實用教程
- 快速念咒:MySQL入門指南與進階實戰
- Learning Hunk
- ServiceNow:Building Powerful Workflows
- Python語言科研繪圖與學術圖表繪制從入門到精通
- Mockito Essentials
- Kotlin Programming By Example
- Flink技術內幕:架構設計與實現原理
- PHP 8從入門到精通(視頻教學版)
- AutoCAD基礎教程