Edit

Share via


New-AzAutomationVariable

Creates an Automation variable.

Syntax

Default (Default)

New-AzAutomationVariable
    [-Name] <String>
    -Encrypted <Boolean>
    [-Description <String>]
    [-Value <Object>]
    [-ResourceGroupName] <String>
    [-AutomationAccountName] <String>
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The New-AzAutomationVariable cmdlet creates a variable in Azure Automation. To encrypt the variable, specify the Encrypted parameter. You cannot modify the encrypted state of a variable after creation.

Examples

Example 1: Create a variable with a simple value

New-AzAutomationVariable -AutomationAccountName "Contoso17" -Name "StringVariable22" -Encrypted $False -Value "My String" -ResourceGroupName "ResourceGroup01"

This command creates a variable named StringVariable22 with a string value in the Automation account named Contoso17.

Example 2: Create a variable with a complex value

$VirtualMachine = Get-AzVM -Name "VirtualMachine03"
New-AzAutomationVariable -AutomationAccountName "Contoso17" -Name "ComplexVariable01" -Encrypted $False -Value $VirtualMachine -ResourceGroupName "ResourceGroup01"

The first command gets a virtual machine by using the Get-AzVM cmdlet. The command stores it in the $VirtualMachine variable. The second command creates a variable named ComplexVariable01 in the Automation account named Contoso17. This command uses a complex object for its value, in this case, the virtual machine in $VirtualMachine.

Parameters

-AutomationAccountName

Specifies the name of the Automation account in which to store the variable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Description

Specifies a description for the variable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Encrypted

Specifies whether this cmdlet encrypts the value of the variable for storage.

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Name

Specifies a name for the variable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ResourceGroupName

Specifies the resource group for which this cmdlet creates a variable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Value

Specifies a value for the variable.

Parameter properties

Type:Object
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

Boolean

Object

Outputs

Variable