Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
New-AzAutomationVariable
- Module:
- Az.Automation Module
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
-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
-Description
Specifies a description for the variable.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-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
-Name
Specifies a name for the variable.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-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
-Value
Specifies a value for the variable.
Parameter properties
| Type: | Object |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
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
Related Links
Azure PowerShell
Feedback
Was this page helpful?
