Windows desktop applications
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Provider cmdlet dynamic parameters

Providers can define dynamic parameters that are added to a provider cmdlet when the user specifies a certain value for one of the static parameters of the cmdlet. For example, a provider can add different dynamic parameters based on what path the user specifies when they call the Get-Item or Set-Item provider cmdlets.

Dynamic Parameter Methods

Dynamic parameters are defined by implementing one of the dynamic parameter methods, such as the GetItemDynamicParameters and SetItemDynamicParameterss methods. These methods return an object that has public properties that are decorated with attributes similar to those of stand-alone cmdlets. Here is an example of an implementation of the GetItemDynamicParameters method taken from the Certificate provider:

    protected override object GetItemDynamicParameters(string path)
    {
        return new CertificateProviderDynamicParameters();
    }

Unlike the static parameters of provider cmdlets, you can specify the characteristics of these parameters in the same way that parameters are defined in stand-alone cmdlets. Here is an example of a dynamic parameter class taken from the Certificate provider:

  internal sealed class CertificateProviderDynamicParameters
  {
    /// <summary>
    /// Dynamic parameter the controls whether we only return 
    /// code signing certs.
    /// </summary>
    [Parameter()]
    public SwitchParameter CodeSigningCert
    {
      get
      {
        {
          return codeSigningCert;
        }
      }

      set
      {
        {
          codeSigningCert = value;
        }
      }
    }

      private SwitchParameter codeSigningCert = new SwitchParameter();
  }

Dynamic Parameters

Here is a list of the static parameters that can be used to add dynamic parameters.

Clear-Content cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Clear-Clear cmdlet by implementing the ClearContentDynamicParameters method.

Clear-Item cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Clear-Item cmdlet by implementing the ClearItemDynamicParameters method.

Clear-ItemProperty cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Clear-ItemProperty cmdlet by implementing the ClearPropertyDynamicParameters method.

Copy-Item cmdlet
You can define dynamic parameters that are triggered by the Path, Destination, and Recurse parameters of the Copy-Item cmdlet by implementing the CopyItemDynamicParameters method.

Get-ChildItems cmdlet
You can define dynamic parameters that are triggered by the Path and Recures parameters of the Get-ChildItem cmdlet by implementing the GetChildItemsDynamicParameters and GetChildNamesDynamicParameters methods.

Get-Content cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Get-Content cmdlet by implementing the GetContentReaderDynamicParameters method.

Get-Item cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Get-Item cmdlet by implementing the GetItemDynamicParameters method.

Get-ItemProperty cmdlet
You can define dynamic parameters that are triggered by the Path and Name parameters of the Get-ItemProperty cmdlet by implementing the GetPropertyDynamicParameters method.

Invoke-Item cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Invoke-Item cmdlet by implementing the InvokeDefaultActionDynamicParameters method.

Move-Item cmdlet
You can define dynamic parameters that are triggered by the Path and Destination parameters of the Move-Item cmdlet by implementing the MoveItemDynamicParameters method.

New-Item cmdlet
You can define dynamic parameters that are triggered by the Path, ItemType, and Value parameters of the New-Item cmdlet by implementing the NewItemDynamicParameters method.

New-ItemProperty cmdlet
You can define dynamic parameters that are triggered by the Path, Name, PropertyType, and Value parameters of the New-ItemProperty cmdlet by implementing the NewPropertyDynamicParameters method.

New-PSDrive cmdlet
You can define dynamic parameters that are triggered by the PSDriveInfo object returned by the New-PSDrive cmdlet by implementing the NewDriveDynamicParameters method.

Remove-Item
You can define dynamic parameters that are triggered by the Path and Recurse parameters of the Remove-Item cmdlet by implementing the RemoveItemDynamicParameters method.

Remove-ItemProperty
You can define dynamic parameters that are triggered by the Path and Name parameters of the Remove-ItemProperty cmdlet by implementing the RemovePropertyDynamicParameters method.

Rename-Item cmdlet
You can define dynamic parameters that are triggered by the Path and NewName parameters of the Rename-Item cmdlet by implementing the RenameItemDynamicParameters method.

Rename-ItemProperty
You can define dynamic parameters that are triggered by the Path, Name, and NewName parameters of the Rename-ItemProperty cmdlet by implementing the RenamePropertyDynamicParameters method.

Set-Content cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Set-Content cmdlet by implementing the GetContentWriterDynamicParameters method.

Set-Item cmdlet
You can define dynamic parameters that are triggered by the Path and Value parameters of the Set-Item cmdlet by implementing the SetItemDynamicParameters method.

Set-ItemProperty cmdlet
You can define dynamic parameters that are triggered by the Path and Value parameters of the Set-Item cmdlet by implementing the SetPropertyDynamicParameters method.

Test-Path cmdlet
You can define dynamic parameters that are triggered by the Path parameter of the Test-Path cmdlet by implementing the InvokeDefaultActionDynamicParameters method.

See Also

Community Additions

Show:
© 2016 Microsoft