Share via


Windows PowerShell Provider Capabilities

Provider capabilities are features that are either implemented or supported by the provider. When a capability is specified, the Windows PowerShell runtime performs the operation using its own implementation; however, in the cases where the provider is allowed to provide its own implementation (such as include or exclude capabilities), a provider-implemented capability will typically perform better than the implementation provided by the Windows PowerShell runtime.

Note

For more information about provider functionality that is based on the implementation of provider base classes and interfaces, see Designing Your Windows PowerShell Provider.

Provider Capabilities

The following capabilities can be specified when implementing the provider class. These capabilities are defined by the ProviderCapabilities enumeration.

  • Credentials: The provider supports the use of credentials passed to it from the command line. When this capability is supported and the user supplies credentials on the command line, the Credential property of the provider class is populated with those credentials.

  • Exclude: The provider has the ability to exclude items in the data store based on a wildcard string.

  • ExpandWildcards: The provider supports the ability to handle wildcards within a provider internal path.

  • Filter: The provider implements the ability to perform additional filtering based on some provider-specific string.

  • Include: The provider has the ability to include items in the data store based on a wildcard string.

  • None: The provider does not support features other than features provided by the derived base class and implemented interfaces.

  • ShouldProcess: The provider supports calls to the ShouldProcess method before its provider cmdlets perform an action. This capability allows the user to use the WhatIf parameter with confidence.

  • Transactions: The provider supports the use of its provider cmdlets within a transaction. This allows the user to accept or reject the actions of provider cmdlets that participated in the transaction.

Specifying Provider Capabilities

Provider capabilities are specified when decorating the provider class definition with the CmdletProvider attribute. For example, here is the CmdletProvider attribute for the Registry provider. The first parameter of the attribute specifies the name of the provider, and the second parameter specifies the provider capabilities. In this case, the Registry provider supports calls to the ShouldProcess method (which allows the provider to confirm an action before it performs the action) and supports transactions.

[CmdletProvider(RegistryProvider.ProviderName, ProviderCapabilities.ShouldProcess | ProviderCapabilities.Transactions)]
   

See Also

Concepts

Designing Your Windows PowerShell Provider

Other Resources

Writing a Windows PowerShell Provider