Skip to content

Commit 29e603c

Browse files
PsCustomObjectPsCustomObject
authored andcommitted
Updated commands splatting in post code
1 parent 172d983 commit 29e603c

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

_posts/2020-09-25-Azure-Automation-Variables.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ An unencrypted variable can be created in the Azure portal going to **[Automatio
6363
The 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
6977
Value : Test Value
@@ -90,7 +98,15 @@ As you can see values of the variable is visible both in the PowerShell output a
9098
Creation *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
96112
Value :
@@ -124,7 +140,15 @@ Now that we know how to create azure automation variables let's see how to work
124140
Or 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
129153
Value : Setting new value from PowerShell
130154
Encrypted : False
@@ -146,7 +170,15 @@ When working with an encrypted variable things will be slightly different. **Enc
146170
From 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
151183
Value :
152184
Encrypted : 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
169201
Value : Setting new value from PowerShell
170202
Encrypted : False

0 commit comments

Comments
 (0)