Windows PowerShell Providers

 

SHORT DESCRIPTION

Windows PowerShell providers provide access to data and components that would not otherwise be easily accessible at the command line. The data is presented in a consistent format that resembles a file system drive.

 

LONG DESCRIPTION

Windows PowerShell providers are .NET programs that make the data in a specialized data store available in Windows PowerShell so that you can easily view and manage it.

 

The data that a provider exposes appears in a drive, much like a hard drive. You can use any of the built-in cmdlets that the provider supports to manage the data in the provider drive, in addition to custom cmdlets that are designed especially for the data.

 

The providers can also add "dynamic parameters" to the built-in cmdlets. These are parameters that are available only when using the cmdlet with the provider data.

 

BUILT-IN PROVIDERS

Windows PowerShell includes a set of built-in providers that you can use to access the different types of data stores:

 

Provider 

Data Store

Alias

Windows PowerShell aliases

Certificate  

X509 certificates for digital signatures

Environment  

Windows environment variables

FileSystem

File system drives, directories and files

Function 

Windows PowerShell functions

Registry 

Windows registry

Variable 

Windows PowerShell variables

 

You can also create your own Windows PowerShell providers and install providers that others develop. To list the providers that are available in your Windows PowerShell session, type "Get-PsProvider".

 

INSTALLING AND REMOVING PROVIDERS

Windows PowerShell providers are delivered to you in Windows PowerShell snap-ins, which are .NET programs that are compiled into DLL files. The snap-ins can include providers and cmdlets.

 

Before using the provider features, you need to install the snap-in and add it to your Windows PowerShell console. For instructions, see About_PsSnapins.

 

You can not uninstall a provider, although you can remove the Windows PowerShell snap-in for the provider from the current console. If you do, you will remove all of the contents of the snap-in, including cmdlets.

 

To remove a provider from the current console, use the Remove-PsSnapin cmdlet. This cmdlet does not unload or uninstall the provider, but it makes the provider unavailable in the console.

 

You can also use the Remove-PsDrive cmdlet to remove any drive from the current console. This data on the drive is not affected, but the drive is no longer available in that console session.

 

VIEWING PROVIDERS

To find the Windows PowerShell providers on your system, type:

 

Get-PsProvider

 

The display lists the built-in providers and providers that you added to the console.

 

Name

Capabilities

Drives

Alias

ShouldProcess

{Alias}

Environment 

ShouldProcess

{Env}

FileSystem  

Filter, ShouldProcess

{C, D, Z}

Function

ShouldProcess

{Function}

Registry

ShouldProcess

{HKLM, HKCU}

Variable

ShouldProcess

{Variable}

Certificate 

ShouldProcess

{cert}

 

VIEWING PROVIDER DATA

The primary benefit of a provider is that it exposes its data in a familiar and consistent way. The model is for data presentation is a file system drive.

 

To use data that the provider exposes, you view it, navigate through it, and change it as though it were data in a hard drive. Therefore, the most important bit of information about the provider is the name of the drive that it supports.

 

The drive is listed in the default display of Get-PsProvider, but you can get information about the provider drive by using the Get-PsDrive cmdlet. For example, to find all of the properties of the Function drive, type:

 

get-psdrive Function | format-list *

 

You can view and navigate through the data in a provider drive just as you would in a file system drive.

 

To view the contents of a provider drive, use the Get-Item or Get-Childitem cmdlets. Type the drive name, followed by a colon (:). For example, to view the contents of the Alias drive, type:

 

get-item alias:

 

You can view and manage the data in any drive from another drive by including the drive name in the path. For example, to view the HKLM\Software registry key in the HKLM: drive from another drive, type:

 

get-childitem hklm:\software

 

To get into the drive, use the Set-Location cmdlet. Remember the colon when specifying the drive path. For example, to change your location to the root of the Cert: drive, type:

 

set-location cert:

 

Then, to view the contents of the Cert: drive, type:

 

get-childitem

 

Just be sure to remember the colon (:) in the drive name.

 

NAVIGATING THROUGH HIERARCHICAL DATA

You can navigate through a provider drive just as you would a hard drive. If the data is arranged in a hierarchy of items within items, use a backslash (\) to indicate a child item. The format is:

 

drive:\location\child-location\...

 

For example, to change your location to the HKLM\Software registry key, use a Set-Location command, such as:

 

set-location cert:\CurrentUser

 

You can also use relative references to locations. A dot (.) represents the current location. For example, if you are in the HKLM:\Software\Microsoft registry key and you want to list the subkeys in the HKLM:\Software\Micrsoft\PowerShell key, use the following command:

 

get-childitem .\PowerShell

 

FINDING DYNAMIC PARAMETERS

Dynamic parameters are cmdlet parameters that are available only when the cmdlet is used in the provider drive. These parameters add valuable features to the cmdlets.

 

For example, the CodeSigningCert parameter is added to Get-Item and Get-Childitem when it is used with data from the Cert: drive.

 

For a list of the dynamic parameters that a provider supports, see the About file for the provider.

 

LEARNING ABOUT PROVIDERS

Although all provider data appears in drives and you use the same methods to navigate through them, the similarity of stops there. The data stores that the provider expose can be as varied as Active Directory locations and Microsoft Exchange mailboxes.

 

For information about individual Windows PowerShell providers, type Get-Help <ProviderName> –Category Provider.

 

SEE ALSO

  

For information about working locations, type:

 

help about_location

 

For information about path syntax, type:

 

help about_path_syntax