New-​Azure​Rm​Automation​Variable

Creates an Automation variable.

Syntax

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

Description

The New-AzureRmAutomationVariable 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

PS C:\>New-AzureRmAutomationVariable -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

PS C:\>$VirtualMachine = Get-AzureVM -ServiceName "VirtualMachine" -Name "VirtualMachine03"
PS C:\> New-AzureRmAutomationVariable -AutomationAccountName "Contoso17" -Name "ComplexVariable01" -Encrypted $False -Value $VirtualMachine -ResourceGroupName "ResourceGroup01"

The first command gets a virtual machine by using the Get-AzureVM 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.

Required Parameters

-AutomationAccountName

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

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Encrypted

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

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Name

Specifies a name for the variable.

Type:String
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceGroupName

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

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Description

Specifies a description for the variable.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Value

Specifies a value for the variable.

Type:Object
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False