Editar

Compartir a través de


New-AzAutomationVariable

Creates an Automation variable.

Syntax

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.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Description

Specifies a description for the variable.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Encrypted

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

Type:Boolean
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies a name for the variable.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

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

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Value

Specifies a value for the variable.

Type:Object
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

Inputs

String

Boolean

Object

Outputs

Variable