New-AzAutomationVariable
语法
Default (默认值)
New-AzAutomationVariable
[-Name] <String>
-Encrypted <Boolean>
[-Description <String>]
[-Value <Object>]
[-ResourceGroupName] <String>
[-AutomationAccountName] <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
New-AzAutomationVariable cmdlet 在Azure 自动化中创建变量。
若要加密变量,请指定 Encrypted 参数。
创建后无法修改变量的加密状态。
示例
示例 1:创建具有简单值的变量
New-AzAutomationVariable -AutomationAccountName "Contoso17" -Name "StringVariable22" -Encrypted $False -Value "My String" -ResourceGroupName "ResourceGroup01"
此命令使用名为 Contoso17 的自动化帐户中的字符串值创建名为 StringVariable22 的变量。
示例 2:创建具有复杂值的变量
$VirtualMachine = Get-AzVM -Name "VirtualMachine03"
New-AzAutomationVariable -AutomationAccountName "Contoso17" -Name "ComplexVariable01" -Encrypted $False -Value $VirtualMachine -ResourceGroupName "ResourceGroup01"
第一个命令使用 Get-AzVM cmdlet 获取虚拟机。
该命令将其存储在$VirtualMachine变量中。
第二个命令在名为 Contoso17 的自动化帐户中创建名为 ComplexVariable01 的变量。
此命令使用复杂对象作为其值,在本例中为$VirtualMachine中的虚拟机。
参数
-AutomationAccountName
指定要在其中存储变量的自动化帐户的名称。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | 1 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-DefaultProfile
用于与 azure 通信的凭据、帐户、租户和订阅
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Description
指定变量的说明。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-Encrypted
指定此 cmdlet 是否加密存储变量的值。
参数属性
类型: | Boolean
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-Name
指定变量的名称。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | 2 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-ResourceGroupName
指定此 cmdlet 为其创建变量的资源组。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-Value
指定变量的值。
参数属性
类型: | Object
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输出