CommandMetadata CommandMetadata CommandMetadata CommandMetadata Class


This class represents the compiled metadata for a command type.

public ref class CommandMetadata sealed
[System.Diagnostics.DebuggerDisplay("CommandName = {Name}; Type = {CommandType}")]
public sealed class CommandMetadata
type CommandMetadata = class
Public NotInheritable Class CommandMetadata


CommandMetadata(CommandInfo) CommandMetadata(CommandInfo) CommandMetadata(CommandInfo) CommandMetadata(CommandInfo)

Construct a CommandMetadata object for the given commandInfo

CommandMetadata(CommandMetadata) CommandMetadata(CommandMetadata) CommandMetadata(CommandMetadata) CommandMetadata(CommandMetadata)

A copy constructor that creates a deep copy of the other CommandMetadata object. Instances of Attribute and Type classes are copied by reference.

CommandMetadata(String) CommandMetadata(String) CommandMetadata(String) CommandMetadata(String)

Construct a CommandMetadata object for a script file.

CommandMetadata(Type) CommandMetadata(Type) CommandMetadata(Type) CommandMetadata(Type)

Constructs a CommandMetada object for the given CLS complaint type commandType.

CommandMetadata(CommandInfo, Boolean) CommandMetadata(CommandInfo, Boolean) CommandMetadata(CommandInfo, Boolean) CommandMetadata(CommandInfo, Boolean)

Construct a CommandMetadata object for the given commandInfo


CommandType CommandType CommandType CommandType

The Type which this CommandMetadata represents.

ConfirmImpact ConfirmImpact ConfirmImpact ConfirmImpact

Indicates the "destructiveness" of the command operation and when it should be confirmed. This is only effective when the command calls ShouldProcess, which should only occur when SupportsShouldProcess is specified.

DefaultParameterSetName DefaultParameterSetName DefaultParameterSetName DefaultParameterSetName

Gets/Sets the default parameter set name

HelpUri HelpUri HelpUri HelpUri

Related link URI for Get-Help -Online

Name Name Name Name

Gets the name of the command this metadata represents

Parameters Parameters Parameters Parameters

Gets the parameter data for this command

PositionalBinding PositionalBinding PositionalBinding PositionalBinding

When true, the command will auto-generate appropriate parameter metadata to support positional parameters if the script hasn't already specified multiple parameter sets or specified positions explicitly via the ParameterAttribute.

RemotingCapability RemotingCapability RemotingCapability RemotingCapability

The remoting capabilities of this cmdlet, when exposed in a context with ambient remoting.

SupportsPaging SupportsPaging SupportsPaging SupportsPaging

True if the cmdlet declared that it supports Paging, false otherwise.

SupportsShouldProcess SupportsShouldProcess SupportsShouldProcess SupportsShouldProcess

True if the cmdlet declared that it supports ShouldProcess, false otherwise.

SupportsTransactions SupportsTransactions SupportsTransactions SupportsTransactions

True if the cmdlet declared that it supports transactions, false otherwise.


GetRestrictedCommands(SessionCapabilities) GetRestrictedCommands(SessionCapabilities) GetRestrictedCommands(SessionCapabilities) GetRestrictedCommands(SessionCapabilities)

Returns a dictionary from a command name to CommandMetadata describing how that command can be restricted to limit attack surface while still being usable by features included in sessionCapabilities.

For example the implicit remoting feature (included in RemoteServer) doesn't use all parameters of Get-Help and uses only a limited set of argument values for the parameters it does use.

CommandMetadata can be passed to Create(CommandMetadata) method to generate a body of a proxy function that forwards calls to the actual cmdlet, while exposing only the parameters listed in CommandMetadata. Exposing only the restricted proxy function while making the actual cmdlet and its aliases private can help in reducing attack surface of the remoting server.

Applies to