CommandMetadata Class

Definition

This class represents the compiled metadata for a command type.

public sealed class CommandMetadata
Inheritance
CommandMetadata

Constructors

CommandMetadata(CommandInfo)

Construct a CommandMetadata object for the given commandInfo

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)

Construct a CommandMetadata object for a script file.

CommandMetadata(Type)

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

CommandMetadata(CommandInfo, Boolean)

Construct a CommandMetadata object for the given commandInfo

Properties

CommandType

The Type which this CommandMetadata represents.

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

Gets/Sets the default parameter set name

HelpUri

Related link URI for Get-Help -Online

Name

Gets the name of the command this metadata represents

Parameters

Gets the parameter data for this command

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

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

SupportsPaging

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

SupportsShouldProcess

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

SupportsTransactions

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

Methods

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 <xref href="System.Management.Automation.SessionCapabilities.RemoteServer"></xref>) 
        doesn't use all parameters of Get-Help 
        and uses only a limited set of argument values for the parameters it does use.

        <xref href="System.Management.Automation.CommandMetadata"></xref> can be passed to <xref href="System.Management.Automation.ProxyCommand.Create(System.Management.Automation.CommandMetadata)"></xref> method to generate
        a body of a proxy function that forwards calls to the actual cmdlet, while exposing only the parameters
        listed in <xref href="System.Management.Automation.CommandMetadata"></xref>.  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.