다음을 통해 공유


PSVariable Constructors

Definition

Overloads

PSVariable(String)

Constructs a variable with the given name.

PSVariable(String, Object)

Constructs a variable with the given name, and value.

PSVariable(String, Object, ScopedItemOptions)

Constructs a variable with the given name, value, and options.

PSVariable(String, Object, ScopedItemOptions, Collection<Attribute>)

Constructs a variable with the given name, value, options, and attributes.

PSVariable(String)

Constructs a variable with the given name.

public:
 PSVariable(System::String ^ name);
public:
 PSVariable(Platform::String ^ name);
 PSVariable(std::wstring const & name);
public PSVariable (string name);
new System.Management.Automation.PSVariable : string -> System.Management.Automation.PSVariable
Public Sub New (name As String)

Parameters

name
String

The name of the variable.

Exceptions

If name is null or empty.

Applies to

PSVariable(String, Object)

Constructs a variable with the given name, and value.

public:
 PSVariable(System::String ^ name, System::Object ^ value);
public:
 PSVariable(Platform::String ^ name, Platform::Object ^ value);
 PSVariable(std::wstring const & name, winrt::Windows::Foundation::IInspectable const & value);
public PSVariable (string name, object value);
new System.Management.Automation.PSVariable : string * obj -> System.Management.Automation.PSVariable
Public Sub New (name As String, value As Object)

Parameters

name
String

The name of the variable.

value
Object

The value of the variable.

Exceptions

If name is null or empty.

Applies to

PSVariable(String, Object, ScopedItemOptions)

Constructs a variable with the given name, value, and options.

public:
 PSVariable(System::String ^ name, System::Object ^ value, System::Management::Automation::ScopedItemOptions options);
public PSVariable (string name, object value, System.Management.Automation.ScopedItemOptions options);
new System.Management.Automation.PSVariable : string * obj * System.Management.Automation.ScopedItemOptions -> System.Management.Automation.PSVariable
Public Sub New (name As String, value As Object, options As ScopedItemOptions)

Parameters

name
String

The name of the variable.

value
Object

The value of the variable.

options
ScopedItemOptions

The constraints of the variable. Note, variables can only be made constant in the constructor.

Exceptions

If name is null or empty.

Applies to

PSVariable(String, Object, ScopedItemOptions, Collection<Attribute>)

Constructs a variable with the given name, value, options, and attributes.

public:
 PSVariable(System::String ^ name, System::Object ^ value, System::Management::Automation::ScopedItemOptions options, System::Collections::ObjectModel::Collection<Attribute ^> ^ attributes);
public PSVariable (string name, object value, System.Management.Automation.ScopedItemOptions options, System.Collections.ObjectModel.Collection<Attribute> attributes);
new System.Management.Automation.PSVariable : string * obj * System.Management.Automation.ScopedItemOptions * System.Collections.ObjectModel.Collection<Attribute> -> System.Management.Automation.PSVariable
Public Sub New (name As String, value As Object, options As ScopedItemOptions, attributes As Collection(Of Attribute))

Parameters

name
String

The name of the variable.

value
Object

The value of the variable.

options
ScopedItemOptions

The constraints of the variable. Note, variables can only be made constant in the constructor.

attributes
Collection<Attribute>

The attributes for the variable. ValidateArgumentsAttribute and derived types will be used to validate a value before setting it.

Exceptions

If name is null or empty.

If the validation metadata identified in attributes throws an exception.

Applies to