Provider Drives

Drives are the entry points to the data store of your provider. They are virtual drives that can be used to navigate the data store in the same way that system drives are used to navigate the file system. (These drives cannot be seen from outside of Windows PowerShell, such as from command.exe.) For example, the Windows PowerShell Registry provider defines two drives, HKCU and HKLM, that the user can use to access the HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE hives, respectively, of the Windows Registry.

Specifying a Drive

Users do not explicitly specify which provider they want to access a data store. Instead, they include which drive they want to use when providing a path to a provider cmdlet. Here are some examples of path statements that include a drive. For more information about specifying paths, see Provider Paths.

get-item hklm:

get-item C:

Creating Drives

Providers can define the default drives that users can include in their path statements, and they can overwrite the New-PSDrive cmdlet to allow users to create their own drives for the data store. The following classes and methods are used to manage the drives of a provider:

  • PSDriveInfo
    Provides information about the drive, such as its name and the root of the drive in the data store.
  • NewDrive
    Overwriting this method allows the user to create drives for the data store of the provider.
  • NewDriveDynamicParameters
    Overwriting this method allows you to add parameters to the New-PSDrive cmdlet that would be available only when adding drives to the data store of the provider.
  • RemoveDrive
    Overwriting this method allows the provider to clean up any drive-specific data that was used by the provider.