Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 System.Management.Automation.Provider.ItemCmdletProvider.GetItemDynamicParameters* and System.Management.Automation.Provider.SetItemDynamicParameters.SetItemDynamicParameters* 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 System.Management.Automation.Provider.ItemCmdletProvider.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 thePath
parameter of the Clear-Clear cmdlet by implementing the System.Management.Automation.Provider.IContentCmdletProvider.ClearContentDynamicParameters* method.Clear-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
parameter of theClear-Item
cmdlet by implementing the System.Management.Automation.Provider.ItemCmdletProvider.ClearItemDynamicParameters* method.Clear-ItemProperty
cmdlet - You can define dynamic parameters that are triggered by thePath
parameter of theClear-ItemProperty
cmdlet by implementing the System.Management.Automation.Provider.IPropertyCmdletProvider.ClearPropertyDynamicParameters* method.Copy-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
,Destination
, andRecurse
parameters of theCopy-Item
cmdlet by implementing the System.Management.Automation.Provider.ContainerCmdletProvider.CopyItemDynamicParameters* method.Get-ChildItem
cmdlet - You can define dynamic parameters that are triggered by thePath
andRecurse
parameters of theGet-ChildItem
cmdlet by implementing the System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItemsDynamicParameters* and System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNamesDynamicParameters* methods.Get-Content
cmdlet - You can define dynamic parameters that are triggered by thePath
parameter of theGet-Content
cmdlet by implementing the System.Management.Automation.Provider.IContentCmdletProvider.GetContentReaderDynamicParameters* method.Get-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
parameter of theGet-Item
cmdlet by implementing the System.Management.Automation.Provider.ItemCmdletProvider.GetItemDynamicParameters* method.Get-ItemProperty
cmdlet - You can define dynamic parameters that are triggered by thePath
andName
parameters of theGet-ItemProperty
cmdlet by implementing the System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters* method.Invoke-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
parameter of theInvoke-Item
cmdlet by implementing the System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultActionDynamicParameters* method.Move-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
andDestination
parameters of theMove-Item
cmdlet by implementing the System.Management.Automation.Provider.NavigationCmdletProvider.MoveItemDynamicParameters* method.New-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
,ItemType
, andValue
parameters of theNew-Item
cmdlet by implementing the System.Management.Automation.Provider.ContainerCmdletProvider.NewItemDynamicParameters* method.New-ItemProperty
cmdlet - You can define dynamic parameters that are triggered by thePath
,Name
,PropertyType
, andValue
parameters of theNew-ItemProperty
cmdlet by implementing the System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.NewPropertyDynamicParameters* method.New-PSDrive
cmdlet - You can define dynamic parameters that are triggered by the System.Management.Automation.PSDriveInfo object returned by theNew-PSDrive
cmdlet by implementing the System.Management.Automation.Provider.DriveCmdletProvider.NewDriveDynamicParameters* method.Remove-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
andRecurse
parameters of theRemove-Item
cmdlet by implementing the System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters* method.Remove-ItemProperty
cmdlet - You can define dynamic parameters that are triggered by thePath
andName
parameters of theRemove-ItemProperty
cmdlet by implementing the System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RemovePropertyDynamicParameters* method.Rename-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
andNewName
parameters of theRename-Item
cmdlet by implementing the System.Management.Automation.Provider.ContainerCmdletProvider.RenameItemDynamicParameters* method.Rename-ItemProperty
- You can define dynamic parameters that are triggered by thePath
,Name
, andNewName
parameters of theRename-ItemProperty
cmdlet by implementing the System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RenamePropertyDynamicParameters* method.Set-Content
cmdlet - You can define dynamic parameters that are triggered by thePath
parameter of theSet-Content
cmdlet by implementing the System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriterDynamicParameters* method.Set-Item
cmdlet - You can define dynamic parameters that are triggered by thePath
andValue
parameters of theSet-Item
cmdlet by implementing the System.Management.Automation.Provider.ItemCmdletProvider.SetItemDynamicParameters* method.Set-ItemProperty
cmdlet - You can define dynamic parameters that are triggered by thePath
andValue
parameters of theSet-Item
cmdlet by implementing the System.Management.Automation.Provider.IPropertyCmdletProvider.SetPropertyDynamicParameters* method.Test-Path
cmdlet - You can define dynamic parameters that are triggered by thePath
parameter of theTest-Path
cmdlet by implementing the System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultActionDynamicParameters* method.