PSVariableIntrinsics.GetValue Method

Definition

Overloads

GetValue(String)

Gets the specified variable value from session state.

GetValue(String, Object)

Gets the specified variable from session state. If the variable is not found the default value is returned.

GetValue(String)

Gets the specified variable value from session state.

public:
 System::Object ^ GetValue(System::String ^ name);
public:
 Platform::Object ^ GetValue(Platform::String ^ name);
winrt::Windows::Foundation::IInspectable GetValue(std::wstring const & name);
public object GetValue (string name);
member this.GetValue : string -> obj
Public Function GetValue (name As String) As Object

Parameters

name
String

The name of the variable to get. The name can contain drive and/or scope specifiers like "ENV:path" or "global:myvar".

Returns

The value of the specified variable.

Exceptions

If name is null.

If the name refers to a provider that could not be found.

If the name refers to a drive that could not be found.

If the provider that the name refers to does not support this operation.

If the provider threw an exception.

Applies to

GetValue(String, Object)

Gets the specified variable from session state. If the variable is not found the default value is returned.

public:
 System::Object ^ GetValue(System::String ^ name, System::Object ^ defaultValue);
public:
 Platform::Object ^ GetValue(Platform::String ^ name, Platform::Object ^ defaultValue);
winrt::Windows::Foundation::IInspectable GetValue(std::wstring const & name, winrt::Windows::Foundation::IInspectable const & defaultValue);
public object GetValue (string name, object defaultValue);
member this.GetValue : string * obj -> obj
Public Function GetValue (name As String, defaultValue As Object) As Object

Parameters

name
String

The name of the variable to get. The name can contain drive and/or scope specifiers like "ENV:path" or "global:myvar".

defaultValue
Object

The default value returned if the variable could not be found.

Returns

The value of the specified variable or the default value if the variable is not found.

Exceptions

If name is null.

If the name refers to a provider that could not be found.

If the name refers to a drive that could not be found.

If the provider that the name refers to does not support this operation.

If the provider threw an exception.

Applies to