| description | AccessDBProviderSample03 |
|---|---|
| ms.date | 09/13/2016 |
| ms.topic | reference |
| title | AccessDBProviderSample03 |
This sample shows how to overwrite the
System.Management.Automation.Provider.ItemCmdletProvider.GetItem*
and
System.Management.Automation.Provider.ItemCmdletProvider.SetItem*
methods to support calls to the Get-Item and Set-Item cmdlets. The provider class in this sample
derives from the
System.Management.Automation.Provider.ItemCmdletProvider
class.
Important
Your provider class will most likely derive from one of the following classes and possibly implement other provider interfaces:
- System.Management.Automation.Provider.ItemCmdletProvider class.
- System.Management.Automation.Provider.ContainerCmdletProvider class. See AccessDBProviderSample04.
- System.Management.Automation.Provider.NavigationCmdletProvider class. See AccessDBProviderSample05.
For more information about choosing which provider class to derive from based on provider features, see Designing Your Windows PowerShell Provider.
This sample demonstrates the following:
- Declaring the
CmdletProviderattribute. - Defining a provider class that derives from the System.Management.Automation.Provider.ItemCmdletProvider class.
- Overwriting the
System.Management.Automation.Provider.DriveCmdletProvider.NewDrive*
method to change the behavior of the
New-PSDrivecmdlet, allowing the user to create new drives. (This sample does not show how to add dynamic parameters to theNew-PSDrivecmdlet.) - Overwriting the System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive* method to support removing existing drives.
- Overwriting the
System.Management.Automation.Provider.ItemCmdletProvider.GetItem*
method to change the behavior of the
Get-Itemcmdlet, allowing the user to retrieve items from the data store. (This sample does not show how to add dynamic parameters to theGet-Itemcmdlet.) - Overwriting the
System.Management.Automation.Provider.ItemCmdletProvider.SetItem*
method to change the behavior of the
Set-Itemcmdlet, allowing the user to update the items in the data store. (This sample does not show how to add dynamic parameters to theGet-Itemcmdlet.) - Overwriting the
System.Management.Automation.Provider.ItemCmdletProvider.ItemExists*
method to change the behavior of the
Test-Pathcmdlet. (This sample does not show how to add dynamic parameters to theTest-Pathcmdlet.) - Overwriting the System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath* method to determine if the provided path is valid.
This sample shows how to overwrite the methods needed to get and set items in a Microsoft Access data base.
:::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample03/AccessDBProviderSample03.cs" range="11-976":::
System.Management.Automation.Provider.ItemCmdletProvider
System.Management.Automation.Provider.ContainerCmdletProvider
System.Management.Automation.Provider.NavigationCmdletProvider