Click to Rate and Give Feedback
MSDN
MSDN Library
Windows PowerShell
 Windows PowerShell Providers

  Switch on low bandwidth view
Windows PowerShell Providers

From a developer perspective, a Windows PowerShell provider is an interface that allows the user to interact with stored data in a consistent way. For example, the FileSystem and Registry providers supplied by Windows PowerShell allow the user to interact with data in the Windows file system and Windows Registry respectively through specific cmdlets. A provider and its cmdlets are typically developed together.

noteNote:
For examples of writing Windows PowerShell providers, see How to Create a Windows PowerShell Provider in the Windows PowerShell Programmer's Guide.

Windows PowerShell Provider Classes

Windows PowerShell defines a set of specific base classes and interfaces for providers. When the classes and interfaces are implemented by a developer, the Windows PowerShell runtime automatically exposes the provider cmdlets to the user in a common way. In addition, it exposes methods for other cmdlet developers to use to access that functionality programmatically.

The following base classes can be used to create a provider. Note that each class is derived from the previous class.

  • CmdletProvider:

    Base class for all other provider classes. This class supports the CmdletProviderAttribute declaration, allows the provider to handle Ctrl+C by overriding StopProcessing, and supplies a number of properties and methods available to all other derived providers.

    Similar to the Cmdlet base class, the CmdletProvider class provides members for accessing session state, invoking commands, supporting the should-process functionality, throwing terminating errors, writing to output streams, and more. However, instead of calling WriteObject, this class provides specific write methods tailored to different circumstances.

  • DriveCmdletProvider

    Derived from the CmdletProvider class. This class supplies the new drive and remove drive operations and allows the provider to initialize default drives (those that the specific provider should supply given the user environment. For example, the file system provider initializes drives for all volumes that are mounted, such as hard drives and CD/DVD devices).

  • ItemCmdletProvider

    Derived from the DriveCmdletProvider class. This class supplies operations that can be used against individual items such as the get, set, and clear item operations, along with the ability to invoke (or execute) items. It does not assume any container or navigation ability.

  • ContainerCmdletProvider

    Derived from the ItemCmdletProvider class. This class supplies operations that can be used against container items such as the rename, remove, copy, and existence operations. In addition, there are some other interfaces to assist in the general manipulation of containers such as getting child items and getting child names.

  • NavigationCmdletProvider

    Derived from the ContainerCmdletProvider class. This class supplies operations that can be used against items for more than one container object, including moving an item and checking if an item is a container.

    The Windows PowerShell provider engine maintains the current location for each drive. It therefore keeps track of where the user is navigating to and from. With this information, it can create the fully qualified and resolved provider internal paths. It does not, however, understand provider internal paths. Therefore, it needs some methods from the Windows PowerShell provider to help parse the internal paths. These methods include MakePath, GetParentPath, and GetChildName.

See Also



Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker