共用方式為


CommandMetadata Class

Definition

This class represents the compiled metadata for a command type.

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

Constructors

CommandMetadata(CommandInfo, Boolean)

Construct a CommandMetadata object for the given commandInfo.

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 CommandMetadata object for the given CLS complaint type commandType.

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 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