@@ -63,7 +63,15 @@ An unencrypted variable can be created in the Azure portal going to **[Automatio
6363The same operation can be achieved via PowerShell assuming the ** Az** module is installed on the system:
6464
6565``` powershell
66- New-AzAutomationVariable -ResourceGroupName $azResourceGroup –AutomationAccountName $azAccount –Name 'Test Variable' –Encrypted $false –Value 'Test Value'
66+ $paramNewAzAutomationVariable = @{
67+ ResourceGroupName = $azResourceGroup
68+ AutomationAccountName = $azAccount
69+ Name = 'Test Variable'
70+ Encrypted = $false
71+ Value = 'Test Value'
72+ }
73+
74+ New-AzAutomationVariable @paramNewAzAutomationVariable
6775
6876# Output
6977Value : Test Value
@@ -90,7 +98,15 @@ As you can see values of the variable is visible both in the PowerShell output a
9098Creation * encrypted* variables is identical in terms of steps in the console and via PowerShell simply requires us to specify the * -Encrypted $True* parameter.
9199
92100``` powershell
93- New-AzAutomationVariable -ResourceGroupName $azResourceGroup –AutomationAccountName $azAccount –Name 'Test Encrypted Variable' –Encrypted $true –Value 'Test Value'
101+ $paramNewAzAutomationVariable = @{
102+ ResourceGroupName = $azResourceGroup
103+ AutomationAccountName = $azAccount
104+ Name = 'Test Encrypted Variable'
105+ Encrypted = $true
106+ Value = 'Test Value'
107+ }
108+
109+ New-AzAutomationVariable @paramNewAzAutomationVariable
94110
95111# Output
96112Value :
@@ -124,7 +140,15 @@ Now that we know how to create azure automation variables let's see how to work
124140Or from PowerShell
125141
126142``` powershell
127- Set-AzAutomationVariable -ResourceGroupName $azResourceGroup -AutomationAccountName $azAccount -Name 'Test Variable' -Value 'Setting new value from PowerShell' -Encrypted $False
143+ $paramSetAzAutomationVariable = @{
144+ ResourceGroupName = $azResourceGroup
145+ AutomationAccountName = $azAccount
146+ Name = 'Test Variable'
147+ Value = 'Setting new value from PowerShell'
148+ Encrypted = $False
149+ }
150+
151+ Set-AzAutomationVariable @paramSetAzAutomationVariable
128152
129153Value : Setting new value from PowerShell
130154Encrypted : False
@@ -146,7 +170,15 @@ When working with an encrypted variable things will be slightly different. **Enc
146170From PowerShell command will not be much different but, again, we will not get back the value from the cmdlet
147171
148172``` powershell
149- Set-AzAutomationVariable -ResourceGroupName $azResourceGroup -AutomationAccountName $azAccount -Name 'Test Encrypted Variable' -Value 'Setting new value from PowerShell' -Encrypted $true
173+ $paramSetAzAutomationVariable = @{
174+ ResourceGroupName = $azResourceGroup
175+ AutomationAccountName = $azAccount
176+ Name = 'Test Encrypted Variable'
177+ Value = 'Setting new value from PowerShell'
178+ Encrypted = $true
179+ }
180+
181+ Set-AzAutomationVariable @paramSetAzAutomationVariable
150182
151183Value :
152184Encrypted : True
@@ -164,7 +196,7 @@ Up to this point we've seen how to create and update Azure Automation variables,
164196* Az* module makes available a cmdlet for the purpose
165197
166198``` powershell
167- PS C:\Users\Lethe> Get-AzAutomationVariable -ResourceGroupName $azureResourceGroup -AutomationAccountName $azureAccount -Name 'Test Variable'
199+ Get-AzAutomationVariable -ResourceGroupName $azureResourceGroup -AutomationAccountName $azureAccount -Name 'Test Variable'
168200
169201Value : Setting new value from PowerShell
170202Encrypted : False
0 commit comments