Defines a variable
Defines a variable using a value provided at build time.
EXAMPLE 1
{
[Define(Value={Get-Random})]$RandomNumber
}.Transpile()EXAMPLE 2
{
[Define(Value={$global:ThisValueExistsAtBuildTime})]$MyVariable
}.Transpile()The value to define. When this value is provided within an attribute as a ScriptBlock, the ScriptBlock will be run at build time.
| Type | Required | Position | PipelineInput |
|---|---|---|---|
[PSObject] |
true | named | false |
The variable the definition will be applied to.
| Type | Required | Position | PipelineInput |
|---|---|---|---|
[VariableExpressionAst] |
true | named | true (ByValue) |
The name of the variable. If define is applied as an attribute of a variable, this does not need to be provided.
| Type | Required | Position | PipelineInput | Aliases |
|---|---|---|---|---|
[String] |
false | named | false | Name |
Define -Value <PSObject> -VariableAst <VariableExpressionAst> [-VariableName <String>] [<CommonParameters>]