about_Providers
Short description
Describes how PowerShell providers provide access to data and components that wouldn't otherwise be easily accessible at the command line. The data is presented in a consistent format that resembles a file system drive.
Long description
PowerShell providers are .NET programs that provide access to specialized data stores for easier viewing and management. The data appears in a drive, and you access the data in a path like you would on a hard disk drive. You can use any of the built-in cmdlets that the provider supports to manage the data in the provider drive. And, you can use custom cmdlets that are designed especially for the data.
The providers can also add dynamic parameters to the built-in cmdlets. These parameters are only available when you use the cmdlet with the provider data.
Built-in providers
PowerShell includes a set of built-in providers that you can use to access the different types of data stores.
Provider | Drive(s) | OutputType |
---|---|---|
Alias | Alias: | System.Management.Automation.AliasInfo |
Certificate | Cert: | Microsoft.PowerShell.Commands.X509StoreLocation |
System.Security.Cryptography.X509Certificates.X509Certificate2 | ||
Environment | Env: | System.Collections.DictionaryEntry |
FileSystem | C: (*) | System.IO.FileInfo |
System.IO.DirectoryInfo | ||
Function | Function: | System.Management.Automation.FunctionInfo |
Registry | HKLM: HKCU: | Microsoft.Win32.RegistryKey |
Variable | Variable: | System.Management.Automation.PSVariable |
WSMan | WSMan: | Microsoft.WSMan.Management.WSManConfigContainerElement |
(*) The FileSystem drives vary on each system.
You can also create your own PowerShell providers, and you can install providers that others develop. To list the providers that are available in your session, type:
Get-PSProvider
Note
The Certificate, Registry, and WSMan providers are only available on the Windows platform.
Installing and removing providers
Providers are typically installed via PowerShell modules. Importing the module loads the provider into your session. You can't uninstall the built-in providers. You can uninstall providers loaded by other modules.
You can unload a provider from the current session using the Remove-Module
cmdlet. This cmdlet doesn't uninstall the provider, but it makes the provider
unavailable in the session.
You can also use the Remove-PSDrive
cmdlet to remove any drive from the
current session. This data on the drive isn't affected, but the drive is no
longer available in that session.
Viewing providers
To view the PowerShell providers on your computer, type:
Get-PSProvider
The output lists the built-in providers and the providers that you added to the session.
The provider cmdlets
The following cmdlets are designed to work with the data exposed by any provider. You can use the same cmdlets in the same way to manage the different types of data that providers expose. After you learn to manage the data of one provider, you can use the same procedures with the data from any provider.
For example, the New-Item
cmdlet creates a new item. In the C:
drive that is
supported by the FileSystem provider, you can use New-Item
to create a new
file or folder. In the drives that are supported by the Registry provider,
you can use New-Item
to create a new registry key. In the Alias:
drive,
you can use New-Item
to create a new alias.
For detailed information about any of the following cmdlets, type:
Get-Help <cmdlet-name> -Detailed
ChildItem cmdlets
Content Cmdlets
Item Cmdlets
ItemProperty cmdlets
- Clear-ItemProperty
- Copy-ItemProperty
- Get-ItemProperty
- Move-ItemProperty
- New-ItemProperty
- Remove-ItemProperty
- Rename-ItemProperty
- Set-ItemProperty
Location cmdlets
Path cmdlets
PSDrive cmdlets
PSProvider Cmdlets
Viewing provider data
The primary benefit of a provider is that it exposes its data in a familiar and consistent way. The model for data presentation is a file system drive.
The provider allows you to view, navigate, and change items in the data store as though they were data in a file system. The data store is accessed by the name of the drive that it supports.
The drive is listed in the default display of the Get-PSProvider
cmdlet, but
you can get information about the provider drive using the Get-PSDrive
cmdlet. For example, to get all the properties of the Function: drive, type:
Get-PSDrive Function | Format-List *
You can view and move through the data in a provider drive just as you would on 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 open the drive, use the Set-Location cmdlet. Remember the colon when you specify the drive path. For example, to change your location to the root directory of the Cert: drive, type:
Set-Location cert:
Then, to view the contents of the Cert: drive, type:
Get-ChildItem
Moving through hierarchical data
You can move through a provider drive just as you would a hard disk drive.
If the data is arranged in a hierarchy of items within items, use a
backslash (\
) to indicate a child item. Use the following format:
drive:\location\child-location\...
For example, to change your location to the HKLM\Software registry key, type a Set-Location command, such as:
Set-Location HKLM:\SOFTWARE\
If any element in the fully qualified name includes spaces, you must enclose
the name in double-quotation marks ("
). The following example shows a fully
qualified path that includes spaces.
"C:\Program Files\Internet Explorer\iexplore.exe"
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 registry subkeys in the
HKLM:\Software\Microsoft\PowerShell
key, type the following command:
Get-ChildItem .\PowerShell
Also, double-dots (..
) refers to the directory or container directly above
your current location. You can use double-dots (..
) to navigate through a
provider hierarchy.
PS HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\> cd ..\..\LanmanWorkstation\Parameters
PS HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters>
Provider Home
Providers also have a Home location. This location is shared by all
PSDrives
backed by the provider. It can be retrieved by viewing the Home
property of the provider.
Get-PSProvider | Format-Table Name, Home
Name Home
---- ----
Registry
Alias
Environment
FileSystem C:\Users\username
Function
Variable
Certificate
The FileSystem provider is the only provider that has a default value for
Home. It's the same value as $Home
. For more information, see
about_Automatic_Variables.
You can set the Home directory for a provider, for the current session, using its property.
(Get-PSProvider FileSystem).Home = "C:\"
The ~
character can be used to represent the provider's home directory.
If the provider doesn't have a Home location set, you see an error.
Cert:\> Set-Location ~
Set-Location : Home location for this provider isn't set. To set the home
location, call "(get-psprovider 'Certificate').Home = 'path'".
At line:1 char:1
+ Set-Location ~
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-Location],
PSInvalidOperationException
...
Finding dynamic parameters
Dynamic parameters are cmdlet parameters that are added to a cmdlet by a provider. These parameters are available only when the cmdlet is used with the provider that added them.
For example, the Cert:
drive adds the CodeSigningCert parameter to the
Get-Item
and Get-ChildItem
cmdlets. You can use this parameter only when you
use Get-Item
or Get-ChildItem
in the Cert:
drive.
For a list of the dynamic parameters that a provider supports, see the Help file for the provider. Type:
Get-Help <provider-name>
For example:
Get-Help certificate
Learning about providers
Although all provider data appears in drives and you use the same methods to move through them, the similarity stops there. The data stores that the provider exposes can be as varied as Active Directory locations and Microsoft Exchange Server mailboxes.
For information about individual PowerShell providers, type:
Get-Help <ProviderName>
For example:
Get-Help registry
For a list of Help topics about the providers, type:
Get-Help * -Category Provider