PowerShell: What is Provider/Datastore

By Xah Lee. Date: . Last updated: .

What is Datastore

A datastore is a type of collections of data. For example:

What is Provider

A provider is a directory-like interface to datastore.

For example, when you type dir (alias of Get-ChildItem) to list directory content, it is done via a provider.

Examples of using different providers:

dir env:
List environment variables.
dir function:
List functions.
dir variable:
List variables.
dir alias:
List aliases. [see PowerShell: List of Aliases]

List providers

List providers.
PS C:\Users\xah\web\xahlee_info\powershell> Get-PSProvider

Name                 Capabilities                                      Drives
----                 ------------                                      ------
Registry             ShouldProcess                                     {HKLM, HKCU}
Alias                ShouldProcess                                     {Alias}
Environment          ShouldProcess                                     {Env}
FileSystem           Filter, ShouldProcess, Credentials                {C, D, Temp}
Function             ShouldProcess                                     {Function}
Variable             ShouldProcess                                     {Variable}

Show Drive Name of a Provider

Because provider is a directory-like interface, therefore it has driver names. You can cd name to start to work with that datastore.

Show the “drive” name of provider.

Sample output

Name           Used (GB)     Free (GB) Provider      Root    CurrentLocation
----           ---------     --------- --------      ----    ---------------
Alias                                  Alias
C                 129.62         92.94 FileSystem    C:\     …xah\web
Cert                                   Certificate   \
D                  52.61        859.85 FileSystem    D:\
Env                                    Environment
Function                               Function
HKCU                                   Registry      HKEY_CURRENT_USER
HKLM                                   Registry      HKEY_LOCAL_MACHINE
Temp              129.62         92.94 FileSystem    C:\Users\xah\AppData\Local\Temp\
Variable                               Variable
WSMan                                  WSMan

For example of using a provider other than directory, see PowerShell: Windows Registry

List Functions

Get-ChildItem function:
List all functions.

Show Function Code

For example, mkdir is a function. To show the code, type (Get-Command mkdir).ScriptBlock




Script Examples