Provider types
Providers define their basic functionality by changing how the provider cmdlets (provided by Windows PowerShell) perform their actions. For example, providers can use the default functionality of the Get-Item cmdlet, or they can change how that cmdlet operates when retrieving items from the data store. The provider functionality described in this topic includes functionality defined by overwriting methods from specific provider base classes and interfaces.
Note |
|---|
For provider features that are pre-defined by Windows PowerShell, see Provider capabilities. |
Drive-enabled providers specify the default drives available to the user and allow the user to add or remove drives. In most cases, providers are drive-enabled providers because they require some default drive to access the data store. However, when writing your own provider you might or might not want to allow the user to create and remove drives.
To create a drive-enabled provider, your provider class must derive from the DriveCmdletProvider class or another class that derives from that class. The DriveCmdletProvider class defines the following methods for implementing the default drives of the provider and supporting the New-PSDrive and Remove-PSDrive cmdlets. In most cases, to support a provider cmdlet you must overwrite the method that the Windows PowerShell engine calls to invoke the cmdlet, such as the NewDrive method for the New-PSDrive cmdlet, and optionally you can overwrite a second method, such as NewDriveDynamicParameters, for adding dynamic parameters to the cmdlet.
The InitializeDefaultDrives method defines the default drives that are available to the user whenever the provider is used.
The NewDrive and NewDriveDynamicParameters methods defines how your provider supports the New-PSDrive provider cmdlet. This cmdlet allows the user to create drives to access the data store.
The RemoveDrive method defines how your provider supports the Remove-PSDrive provider cmdlet. This cmdlet allows the user to remove drives from the data store.
Item-enabled providers allow the user to get, set, or clear the items in the data store. An “item” is an element of the data store that the user can access or manage independently. To create an item-enabled provider, your provider class must derive from the ItemCmdletProvider class or another class that derives from that class.
The ItemCmdletProvider class defines the following methods for implementing specific provider cmdlets. In most cases, to support a provider cmdlet you must overwrite the method that the Windows PowerShell engine calls to invoke the cmdlet, such as the ClearItem method for the Clear-Item cmdlet, and optionally you can overwrite a second method, such as ClearItemDynamicParameters, for adding dynamic parameters to the cmdlet.
The ClearItem and ClearItemDynamicParameters methods define how your provider supports the Clear-Item provider cmdlet. This cmdlet allows the user to remove of the value of an item in the data store.
The GetItem and GetItemDynamicParameters methods define how your provider supports the Get-Item provider cmdlet. This cmdlet allows the user to retrieve data from the data store.
The M:System.Management.Automation.Provider.ItemCmdletProvider.SetItem(System.String) and M:System.Management.Automation.Provider.ItemCmdletProvider.SetItemDynamicParameters(System.String) methods define how your provider supports the Set-Item provider cmdlet. This cmdlet allows the user to update the values of items in the data store.
The InvokeDefaultAction and InvokeDefaultAction methods define how your provider supports the Invoke-Item provider cmdlet. This cmdlet allows the user to perform the default action specified by the item.
The ItemExists and ItemExistsDynamicParameters methods define how your provider supports the Test-Path provider cmdlet. This cmdlet allows the user to determine if all the elements of a path exist.
In addition to the methods used to implement provider cmdlets, the ItemCmdletProvider class also defines the following methods:
The ExpandPath method allows the user to use wildcards when specifying the provider path.
The IsValidPath is used to determine if a path is syntactically and semantically valid for the provider.
Container-enabled providers allow the user to manage items that are containers. A container is a group of child items under a common parent item. To create a container-enabled provider, your provider class must derive from the ContainerCmdletProvider class or another class that derives from that class.
Important |
|---|
Container-enabled providers cannot access data stores that contain nested containers. If a child item of a container is another container, you must implement a navigation-enabled provider. |
The ContainerCmdletProvider class defines the following methods for implementing specific provider cmdlets. In most cases, to support a provider cmdlet you must overwrite the method that the Windows PowerShell engine calls to invoke the cmdlet, such as the CopyItem method for the Copy-Item cmdlet, and optionally you can overwrite a second method, such as CopyItemDynamicParameters, for adding dynamic parameters to the cmdlet.
The CopyItem and CopyItemDynamicParameters methods define how your provider supports the Copy-Item provider cmdlet. This cmdlet allows the user to copy an item from one location to another.
The GetChildItems and GetChildItemsDynamicParameters methods define how your provider supports the Get-ChildItem provider cmdlet. This cmdlet allows the user to retrieve the child items of the parent item.
The GetChildNames and GetChildNamesDynamicParameters methods define how your provider supports the Get-ChildItem provider cmdlet if its Name parameter is specified.
The NewItem and NewItemDynamicParameters methods define how your provider supports the New-Item provider cmdlet. This cmdlet allows the user to create new items in the data store.
The RemoveItem and RemoveItemDynamicParameters methods define how your provider supports the Remove-Item provider cmdlet. This cmdlet allows the user to remove items from the data store.
The RenameItem and RenameItemDynamicParameters methods define how your provider supports the Rename-Item provider cmdlet. This cmdlet allows the user to rename items in the data store.
In addition to the methods used to implement provider cmdlets, the ContainerCmdletProvider class also defines the following methods:
The HasChildItems method can be used by the provider class to determine whether an item has child items.
The ConvertPath method can be used by the provider class to create a new provider-specific path from a specified path.
Navigation-enabled providers allow the user to move items in the data store. To create a navigation-enabled provider, your provider class must derive from the NavigationCmdletProvider class.
The NavigationCmdletProvider class defines the following methods for implementing specific provider cmdlets. In most cases, to support a provider cmdlet you must overwrite the method that the Windows PowerShell engine calls to invoke the cmdlet, such as the MoveItem method for the Move-Item cmdlet, and optionally you can overwrite a second method, such as MoveItemDynamicParameters, for adding dynamic parameters to the cmdlet.
The MoveItem and MoveItemDynamicParameters methods define how your provider supports the Move-Item provider cmdlet. This cmdlet allows the user to move an item from one location in the store to another location.
The MakePath method defines how your provider supports the Join-Path provider cmdlet. This cmdlet allows the user to combine a parent and child path segment to create a provider-internal path.
In addition to the methods used to implement provider cmdlets, the NavigationCmdletProvider class also defines the following methods:
The GetChildName method extracts the name of the child node of a path.
The GetParentPath method extracts the parent part of a path.
The IsItemContainer method determines whether the item is a container item. In this context, a container is a group of child items under a common parent item.
The NormalizeRelativePath method returns a path to an item that is relative to a specified base path.
Content-enabled providers allow the user to clear, get, or set the content of items in a data store. For example, the FileSystem provider allows you to clear, get, and set the content of files in the file system. To create a content enabled provider, your provider class must implement the methods of the IContentCmdletProvider interface.
The IContentCmdletProvider interface defines the following methods for implementing specific provider cmdlets. In most cases, to support a provider cmdlet you must overwrite the method that the Windows PowerShell engine calls to invoke the cmdlet, such as the ClearContent method for the Clear-Content cmdlet, and optionally you can overwrite a second method, such as ClearContentDynamicParameters, for adding dynamic parameters to the cmdlet.
The ClearContent and ClearContentDynamicParameters methods define how your provider supports the Clear-Content provider cmdlet. This cmdlet allows the user to delete the content of an item without deleting the item.
The GetContentReader and GetContentReaderDynamicParameters methods define how your provider supports the Get-Content provider cmdlet. This cmdlet allows the user to retrieve the content of an item. The GetContentReader method returns an IContentReader interface that defines the methods used to read the content.
The GetContentWriter and GetContentWriterDynamicParameters methods define how your provider supports the Set-Content provider cmdlet. This cmdlet allows the user to update the content of an item. The GetContentWriter method returns an IContentWriter interface that defines the methods used to write the content.
Property-enabled providers allow the user to manage the properties of the items in the data store. To create a property-enabled provider, your provider class must implement the methods of the IPropertyCmdletProvider and IDynamicPropertyCmdletProvider interfaces. In most cases, to support a provider cmdlet you must overwrite the method that the Windows PowerShell engine calls to invoke the cmdlet, such as the ClearProperty method for the Clear-Property cmdlet, and optionally you can overwrite a second method, such as ClearPropertyDynamicParameters, for adding dynamic parameters to the cmdlet.
The IPropertyCmdletProvider interface defines the following methods for implementing specific provider cmdlets:
The ClearProperty and ClearPropertyDynamicParameters methods define how your provider supports the Clear-ItemProperty provider cmdlet. This cmdlet allows the user to delete the value of a property.
The GetProperty and GetPropertyDynamicParameters methods define how your provider supports the Get-ItemProperty provider cmdlet. This cmdlet allows the user to retrieve the property of an item.
The SetProperty and SetPropertyDynamicParameters methods define how your provider supports the Set-ItemProperty provider cmdlet. This cmdlet allows the user to update the properties of an item.
The IDynamicPropertyCmdletProvider interface defines the following methods for implementing specific provider cmdlets:
The CopyProperty and CopyPropertyDynamicParameters methods define how your provider supports the Copy-ItemProperty provider cmdlet. This cmdlet allows the user to copy a property and its value from one location to another.
The MoveProperty and MovePropertyDynamicParameters methods define how your provider supports the Move-ItemProperty provider cmdlet. This cmdlet allows the user to move a property and its value from one location to another.
The NewProperty and NewPropertyDynamicParameters methods define how your provider supports the New-ItemProperty provider cmdlet. This cmdlet allows the user to create a new property and set its value.
The RemoveProperty and RemovePropertyDynamicParameters methods define how your provider supports the Remove-ItemProperty cmdlet. This cmdlet allows the user to delete a property and its value.
The RenameProperty and RenamePropertyDynamicParameters methods define how your provider supports the Rename-ItemProperty cmdlet. This cmdlet allows the user to change the name of a property.

