@@ -46,19 +46,19 @@ function CreateRunbook
46
46
param ([string ] $runbookPath , [boolean ] $byName = $false , [string []] $tag , [string ] $description )
47
47
48
48
$runbookName = gci $runbookPath | % {$_.BaseName }
49
- $runbook = Get-AzureAutomationRunbook $accountName | where {$_.Name -eq $runbookName }
49
+ $runbook = Get-AzureRmAutomationRunbook $accountName | where {$_.Name -eq $runbookName }
50
50
if ($runbook.Count -eq 1 )
51
51
{
52
- Remove-AzureAutomationRunbook $accountName - Name $runbookName - Force
52
+ Remove-AzureRmAutomationRunbook $accountName - Name $runbookName - Force
53
53
}
54
54
55
55
if (! $byName )
56
56
{
57
- return New-AzureAutomationRunbook $accountName - Path $runbookPath - Tag $tag - Description $description
57
+ return New-AzureRmAutomationRunbook $accountName - Path $runbookPath - Tag $tag - Description $description
58
58
}
59
59
else
60
60
{
61
- return New-AzureAutomationRunbook $accountName - Name $runbookName - Tag $tag - Description $description
61
+ return New-AzureRmAutomationRunbook $accountName - Name $runbookName - Tag $tag - Description $description
62
62
}
63
63
}
64
64
@@ -81,7 +81,7 @@ function WaitForJobStatus
81
81
{
82
82
Wait-Seconds $interval
83
83
$timeElapse = $timeElapse + $interval
84
- $job = Get-AzureAutomationJob - AutomationAccount $accountName - Id $Id
84
+ $job = Get-AzureRmAutomationJob - AutomationAccount $accountName - Id $Id
85
85
if ($job.Status -eq $Status )
86
86
{
87
87
break
@@ -104,19 +104,19 @@ function Test-RunbookWithParameter
104
104
param ([string ] $runbookPath , [HashTable ] $parameters , [int ]$expectedResult )
105
105
106
106
# Setup
107
- $automationAccount = Get-AzureAutomationAccount - Name $accountName
107
+ $automationAccount = Get-AzureRmAutomationAccount - Name $accountName
108
108
Assert-NotNull $automationAccount " Automation account $accountName does not exist."
109
109
110
110
$runbook = CreateRunbook $runbookPath
111
111
Assert-NotNull $runbook " runBook $runbookPath does not import successfully."
112
- $automationAccount | Publish-AzureAutomationRunbook - Name $runbook.Name
112
+ $automationAccount | Publish-AzureRmAutomationRunbook - Name $runbook.Name
113
113
114
114
# Test
115
- $job = $automationAccount | Start-AzureAutomationRunbook - Name $runbook.Name - Parameters $parameters
115
+ $job = $automationAccount | Start-AzureRmAutomationRunbook - Name $runbook.Name - Parameters $parameters
116
116
WaitForJobStatus - Id $job.Id - Status " Completed"
117
- $jobOutput = $automationAccount | Get-AzureAutomationJobOutput - Id $job.Id - Stream Output
118
- $automationAccount | Remove-AzureAutomationRunbook - Name $runbook.Name - Force
119
- Assert-Throws { $automationAccount | Get-AzureAutomationRunbook - Name $runbook.Name }
117
+ $jobOutput = $automationAccount | Get-AzureRmAutomationJobOutput - Id $job.Id - Stream Output
118
+ $automationAccount | Remove-AzureRmAutomationRunbook - Name $runbook.Name - Force
119
+ Assert-Throws { $automationAccount | Get-AzureRmAutomationRunbook - Name $runbook.Name }
120
120
}
121
121
122
122
<#
@@ -127,20 +127,20 @@ function Test-AutomationStartAndStopRunbook
127
127
{
128
128
param ([string ] $runbookPath )
129
129
130
- $automationAccount = Get-AzureAutomationAccount - Name $accountName
130
+ $automationAccount = Get-AzureRmAutomationAccount - Name $accountName
131
131
Assert-NotNull $automationAccount " Automation account $accountName does not exist."
132
132
133
133
$runbook = CreateRunbook $runbookPath
134
134
Assert-NotNull $runbook " runBook $runbookPath does not import successfully."
135
- $automationAccount | Publish-AzureAutomationRunbook - Name $runbook.Name
135
+ $automationAccount | Publish-AzureRmAutomationRunbook - Name $runbook.Name
136
136
137
137
# Test
138
- $job = Start-AzureAutomationRunbook - Name $runbook.Name - AutomationAccountName $accountName
138
+ $job = Start-AzureRmAutomationRunbook - Name $runbook.Name - AutomationAccountName $accountName
139
139
WaitForJobStatus - Id $job.Id - Status " Running"
140
- $automationAccount | Stop-AzureAutomationJob - Id $job.Id
140
+ $automationAccount | Stop-AzureRmAutomationJob - Id $job.Id
141
141
WaitForJobStatus - Id $job.Id - Status " Stopped"
142
- $automationAccount | Remove-AzureAutomationRunbook - Name $runbook.Name - Force
143
- Assert-Throws { $automationAccount | Get-AzureAutomationRunbook - Name $runbook.Name }
142
+ $automationAccount | Remove-AzureRmAutomationRunbook - Name $runbook.Name - Force
143
+ Assert-Throws { $automationAccount | Get-AzureRmAutomationRunbook - Name $runbook.Name }
144
144
}
145
145
146
146
<#
@@ -154,27 +154,27 @@ function Test-AutomationPublishAndEditRunbook
154
154
$runbook = CreateRunbook $runbookPath $true
155
155
156
156
# Publish Runbook
157
- Publish-AzureAutomationRunbook $accountName - Name $runbook.Name
158
- $publishedRunbook = Get-AzureAutomationRunbook $accountName - Name $runbook.Name
157
+ Publish-AzureRmAutomationRunbook $accountName - Name $runbook.Name
158
+ $publishedRunbook = Get-AzureRmAutomationRunbook $accountName - Name $runbook.Name
159
159
$runbookState = " Published"
160
160
Assert-AreEqual $publishedRunbook.State $runbookState " Runbook should be in $runbookState state"
161
- $publishedRunbookDefn = Get-AzureAutomationRunbookDefinition $accountName - Name $runbook.Name
161
+ $publishedRunbookDefn = Get-AzureRmAutomationRunbookDefinition $accountName - Name $runbook.Name
162
162
163
163
# Edit Runbook
164
- Set-AzureAutomationRunbookDefinition $accountName - Name $runbook.Name - Path $runbookPath - Overwrite
165
- $runbook = Get-AzureAutomationRunbook $accountName - Name $runbook.Name
164
+ Set-AzureRmAutomationRunbookDefinition $accountName - Name $runbook.Name - Path $runbookPath - Overwrite
165
+ $runbook = Get-AzureRmAutomationRunbook $accountName - Name $runbook.Name
166
166
$runbookState = " Edit"
167
167
Assert-AreEqual $runbook.State $runbookState " Runbook should be in $runbookState state"
168
- $editedRunbookDefn = Get-AzureAutomationRunbookDefinition $accountName - Name $runbook.Name - Slot " Draft"
168
+ $editedRunbookDefn = Get-AzureRmAutomationRunbookDefinition $accountName - Name $runbook.Name - Slot " Draft"
169
169
Assert-AreNotEqual $editedRunbookDefn.Content $publishedRunbookDefn.Content " Old content and edited content of the runbook shouldn't be equal"
170
170
171
- Assert-Throws {Set-AzureAutomationRunbookDefinition $accountName - Name $runbook.Name - Path $editRunbookPath - PassThru - ErrorAction Stop}
172
- Set-AzureAutomationRunbookDefinition $accountName - Name $runbook.Name - Path $editRunbookPath - Overwrite
173
- $editedRunbookDefn2 = Get-AzureAutomationRunbookDefinition $accountName - Name $runbook.Name - Slot " Draft"
171
+ Assert-Throws {Set-AzureRmAutomationRunbookDefinition $accountName - Name $runbook.Name - Path $editRunbookPath - PassThru - ErrorAction Stop}
172
+ Set-AzureRmAutomationRunbookDefinition $accountName - Name $runbook.Name - Path $editRunbookPath - Overwrite
173
+ $editedRunbookDefn2 = Get-AzureRmAutomationRunbookDefinition $accountName - Name $runbook.Name - Slot " Draft"
174
174
Assert-AreNotEqual $editedRunbookDefn2.Content $editedRunbookDefn.Content " Old content and edited content of the runbook shouldn't be equal"
175
175
176
- Remove-AzureAutomationRunbook $accountName - Name $runbook.Name - Force
177
- Assert-Throws {Get-AzureAutomationRunbook $accountName - Name $runbook.Name }
176
+ Remove-AzureRmAutomationRunbook $accountName - Name $runbook.Name - Force
177
+ Assert-Throws {Get-AzureRmAutomationRunbook $accountName - Name $runbook.Name }
178
178
179
179
}
180
180
@@ -187,56 +187,56 @@ function Test-AutomationConfigureRunbook
187
187
param ([string ] $runbookPath )
188
188
189
189
# Setup
190
- $automationAccount = Get-AzureAutomationAccount - Name $accountName
190
+ $automationAccount = Get-AzureRmAutomationAccount - Name $accountName
191
191
Assert-NotNull $automationAccount " Automation account $accountName does not exist."
192
192
$runbook = CreateRunbook $runbookPath
193
193
Assert-NotNull $runbook " runbook ($runbookPath ) isn't imported successfully."
194
- Publish-AzureAutomationRunbook - Name $runbook.Name - AutomationAccountName $accountName
194
+ Publish-AzureRmAutomationRunbook - Name $runbook.Name - AutomationAccountName $accountName
195
195
196
196
# Test
197
197
198
198
# Change the runbook configuration
199
- $automationAccount | Set-AzureAutomationRunbook - Name $runbook.Name - LogVerbose $true - LogProgress $false
200
- $runbook = $automationAccount | Get-AzureAutomationRunbook - Name $runbook.Name
199
+ $automationAccount | Set-AzureRmAutomationRunbook - Name $runbook.Name - LogVerbose $true - LogProgress $false
200
+ $runbook = $automationAccount | Get-AzureRmAutomationRunbook - Name $runbook.Name
201
201
Assert-NotNull $runbook " Runbook shouldn't be Null"
202
202
Assert-AreEqual $true $runbook.LogVerbose " Log Verbose mode should be true."
203
203
Assert-AreEqual $false $runbook.LogProgress " Log Progress mode should be false."
204
204
205
205
# Start runbook and wait for job complete
206
- $job = $automationAccount | Start-AzureAutomationRunbook - Name $runbook.Name
206
+ $job = $automationAccount | Start-AzureRmAutomationRunbook - Name $runbook.Name
207
207
WaitForJobStatus - Id $job.Id - Status " Completed"
208
208
209
209
# Check job output streams
210
- $jobOutputs = $automationAccount | Get-AzureAutomationJobOutput - Id $job.Id - Stream " Output"
210
+ $jobOutputs = $automationAccount | Get-AzureRmAutomationJobOutput - Id $job.Id - Stream " Output"
211
211
Assert-AreEqual 1 $jobOutputs.Count
212
212
AssertContains $jobOutputs [0 ].Text " output message" " The output stream is wrong."
213
213
# Verify that verbose streams are logged
214
- $jobVerboseOutputs = Get-AzureAutomationJobOutput $accountName - Id $job.Id - Stream " Verbose"
214
+ $jobVerboseOutputs = Get-AzureRmAutomationJobOutput $accountName - Id $job.Id - Stream " Verbose"
215
215
Assert-AreEqual 1 $jobVerboseOutputs.Count
216
216
AssertContains $jobVerboseOutputs [0 ].Text " verbose message" " The verbose stream is wrong."
217
217
# Verify that progress stream isn't logged
218
- $jobProgressOutputs = Get-AzureAutomationJobOutput - AutomationAccountName $accountName - Id $job.Id - Stream " Progress"
218
+ $jobProgressOutputs = Get-AzureRmAutomationJobOutput - AutomationAccountName $accountName - Id $job.Id - Stream " Progress"
219
219
Assert-AreEqual 0 $jobProgressOutputs.Count
220
220
221
221
# Change the runbook configuration again and start the runbook
222
- Set-AzureAutomationRunbook $accountName - Name $runbook.Name - LogVerbose $false - LogProgress $true
223
- $job = Start-AzureAutomationRunbook $accountName - Name $runbook.Name
222
+ Set-AzureRmAutomationRunbook $accountName - Name $runbook.Name - LogVerbose $false - LogProgress $true
223
+ $job = Start-AzureRmAutomationRunbook $accountName - Name $runbook.Name
224
224
WaitForJobStatus - Id $job.Id - Status " Completed"
225
225
# Verify that progress stream is logged
226
- $jobProgressOutputs = Get-AzureAutomationJobOutput $accountName - Id $job.Id - Stream " Progress"
226
+ $jobProgressOutputs = Get-AzureRmAutomationJobOutput $accountName - Id $job.Id - Stream " Progress"
227
227
Assert-AreNotEqual 0 $jobProgressOutputs.Count
228
228
Assert-AreEqual $jobProgressOutputs [0 ].Type " Progress"
229
229
# Verify that verbose streams aren't logged
230
- $jobVerboseOutputs = Get-AzureAutomationJobOutput $accountName - Id $job.Id - Stream " Verbose"
230
+ $jobVerboseOutputs = Get-AzureRmAutomationJobOutput $accountName - Id $job.Id - Stream " Verbose"
231
231
Assert-AreEqual 0 $jobVerboseOutputs.Count
232
232
233
233
# Check whether the total number of jobs for the runbook is correct
234
- $jobs = Get-AzureAutomationJob $accountName - RunbookName $runbook.Name
234
+ $jobs = Get-AzureRmAutomationJob $accountName - RunbookName $runbook.Name
235
235
Assert-AreEqual 2 $jobs.Count " There should be 2 jobs in total for this runbook."
236
236
237
237
# Remove runbook
238
- $automationAccount | Remove-AzureAutomationRunbook - Name $runbook.Name - Force
239
- Assert-Throws {$automationAccount | Get-AzureAutomationRunbook - Name $runbook.Name }
238
+ $automationAccount | Remove-AzureRmAutomationRunbook - Name $runbook.Name - Force
239
+ Assert-Throws {$automationAccount | Get-AzureRmAutomationRunbook - Name $runbook.Name }
240
240
}
241
241
242
242
<#
@@ -248,24 +248,24 @@ function Test-AutomationSuspendAndResumeJob
248
248
param ([string ] $runbookPath )
249
249
250
250
# Setup
251
- $automationAccount = Get-AzureAutomationAccount $accountName
251
+ $automationAccount = Get-AzureRmAutomationAccount $accountName
252
252
Assert-NotNull $automationAccount " Automation account $accountName does not exist."
253
253
$runbook = CreateRunbook $runbookPath
254
254
255
255
# Test
256
256
257
- $automationAccount | Publish-AzureAutomationRunbook - Name $runbook.Name
257
+ $automationAccount | Publish-AzureRmAutomationRunbook - Name $runbook.Name
258
258
# Start, suspend, and then resume job
259
- $job = Start-AzureAutomationRunbook $accountName - Name $runbook.Name
259
+ $job = Start-AzureRmAutomationRunbook $accountName - Name $runbook.Name
260
260
WaitForJobStatus - Id $job.Id - Status " Running"
261
- Suspend-AzureAutomationJob $accountName - Id $job.Id
261
+ Suspend-AzureRmAutomationJob $accountName - Id $job.Id
262
262
WaitForJobStatus - Id $job.Id - Status " Suspended"
263
- $automationAccount | Resume-AzureAutomationJob - Id $job.Id
263
+ $automationAccount | Resume-AzureRmAutomationJob - Id $job.Id
264
264
WaitForJobStatus - Id $job.Id - Status " Completed"
265
265
266
266
# Remove runbook
267
- Remove-AzureAutomationRunbook - AutomationAccountName $accountName - Name $runbook.Name - Force
268
- Assert-Throws {Get-AzureAutomationRunbook $accountName - Name $runbook.Name }
267
+ Remove-AzureRmAutomationRunbook - AutomationAccountName $accountName - Name $runbook.Name - Force
268
+ Assert-Throws {Get-AzureRmAutomationRunbook $accountName - Name $runbook.Name }
269
269
}
270
270
271
271
<#
@@ -277,67 +277,67 @@ function Test-AutomationStartRunbookOnASchedule
277
277
param ([string ] $runbookPath )
278
278
279
279
# Setup
280
- $automationAccount = Get-AzureAutomationAccount - Name $accountName
280
+ $automationAccount = Get-AzureRmAutomationAccount - Name $accountName
281
281
$runbook = CreateRunbook $runbookPath
282
- Publish-AzureAutomationRunbook $accountName - Name $runbook.Name
282
+ Publish-AzureRmAutomationRunbook $accountName - Name $runbook.Name
283
283
284
284
# Test
285
285
286
286
# Create one time schedule
287
287
$oneTimeScheName = " oneTimeSchedule"
288
- $schedule = Get-AzureAutomationSchedule $accountName | where {$_.Name -eq $oneTimeScheName }
288
+ $schedule = Get-AzureRmAutomationSchedule $accountName | where {$_.Name -eq $oneTimeScheName }
289
289
if ($schedule.Count -eq 1 )
290
290
{
291
- Remove-AzureAutomationSchedule $accountName - Name $oneTimeScheName - Force
291
+ Remove-AzureRmAutomationSchedule $accountName - Name $oneTimeScheName - Force
292
292
}
293
293
$startTime = (Get-Date ).AddMinutes(7 )
294
- New-AzureAutomationSchedule $accountName - Name $oneTimeScheName - OneTime - StartTime $startTime
295
- $oneTimeSchedule = Get-AzureAutomationSchedule $accountName - Name $oneTimeScheName
294
+ New-AzureRmAutomationSchedule $accountName - Name $oneTimeScheName - OneTime - StartTime $startTime
295
+ $oneTimeSchedule = Get-AzureRmAutomationSchedule $accountName - Name $oneTimeScheName
296
296
Assert-NotNull $oneTimeSchedule " $oneTimeScheName doesn't exist!"
297
297
298
298
# Create daily schedule
299
299
$dailyScheName = " dailySchedule"
300
- $schedule = Get-AzureAutomationSchedule $accountName | where {$_.Name -eq $dailyScheName }
300
+ $schedule = Get-AzureRmAutomationSchedule $accountName | where {$_.Name -eq $dailyScheName }
301
301
if ($schedule.Count -eq 1 )
302
302
{
303
- Remove-AzureAutomationSchedule $accountName - Name $dailyScheName - Force
303
+ Remove-AzureRmAutomationSchedule $accountName - Name $dailyScheName - Force
304
304
}
305
305
$startTime = (Get-Date ).AddDays(1 )
306
306
$expiryTime = (Get-Date ).AddDays(3 )
307
- New-AzureAutomationSchedule $accountName - Name $DailyScheName - StartTime $startTime - ExpiryTime $expiryTime - DayInterval 1
308
- $dailySchedule = Get-AzureAutomationSchedule $accountName - Name $dailyScheName
307
+ New-AzureRmAutomationSchedule $accountName - Name $DailyScheName - StartTime $startTime - ExpiryTime $expiryTime - DayInterval 1
308
+ $dailySchedule = Get-AzureRmAutomationSchedule $accountName - Name $dailyScheName
309
309
Assert-NotNull $dailySchedule " $dailyScheName doesn't exist!"
310
310
311
- $runbook = Register-AzureAutomationScheduledRunbook $accountName - Name $runbook.Name - ScheduleName $oneTimeScheName
311
+ $runbook = Register-AzureRmAutomationScheduledRunbook $accountName - Name $runbook.Name - ScheduleName $oneTimeScheName
312
312
Assert-AreEqual $oneTimeScheName $runbook.ScheduleNames " The runbook should be associated with $oneTimeScheName "
313
- $runbook = Register-AzureAutomationScheduledRunbook $accountName - Name $runbook.Name - ScheduleName $dailyScheName
313
+ $runbook = Register-AzureRmAutomationScheduledRunbook $accountName - Name $runbook.Name - ScheduleName $dailyScheName
314
314
Assert-True { $runbook.ScheduleNames -Contains $dailyScheName } " The runbook should be associated with $dailyScheName "
315
315
316
316
# waiting for seven minutes
317
317
Wait-Seconds 420
318
- $job = Get-AzureAutomationJob $accountName - Name $runbook.Name | where {$_.ScheduleName -eq $oneTimeScheName }
319
- $jobSchedule = Get-AzureAutomationScheduledRunbook $accountName - RunbookName $runbook.Name - ScheduleName $oneTimeScheName
318
+ $job = Get-AzureRmAutomationJob $accountName - Name $runbook.Name | where {$_.ScheduleName -eq $oneTimeScheName }
319
+ $jobSchedule = Get-AzureRmAutomationScheduledRunbook $accountName - RunbookName $runbook.Name - ScheduleName $oneTimeScheName
320
320
Assert-AreEqual 1 $jobSchedule.Count
321
321
Assert-AreEqual 1 $job.Count
322
322
WaitForJobStatus - Id $job.Id - Status " Completed"
323
323
324
324
# Edit schedule
325
325
$description = " Daily Schedule Description"
326
- Set-AzureAutomationSchedule $accountName - Name $dailyScheName - Description $description
327
- $dailySchedule = Get-AzureAutomationSchedule $accountName - Name $dailyScheName
326
+ Set-AzureRmAutomationSchedule $accountName - Name $dailyScheName - Description $description
327
+ $dailySchedule = Get-AzureRmAutomationSchedule $accountName - Name $dailyScheName
328
328
Assert-AreEqual $description $dailySchedule.Description
329
329
330
- Unregister-AzureAutomationScheduledRunbook $accountName - Name $runbook.Name - ScheduleName $dailyScheName
331
- $jobSchedule = Get-AzureAutomationScheduledRunbook $accountName - RunbookName $runbook.Name - ScheduleName $dailyScheName
330
+ Unregister-AzureRmAutomationScheduledRunbook $accountName - Name $runbook.Name - ScheduleName $dailyScheName
331
+ $jobSchedule = Get-AzureRmAutomationScheduledRunbook $accountName - RunbookName $runbook.Name - ScheduleName $dailyScheName
332
332
Assert-Null $jobSchedule " The runbook shouldn't have an association with $dailyScheName "
333
333
334
334
# Remove runbook and schedule
335
- Remove-AzureAutomationSchedule $accountName - Name $oneTimeScheName - Force
336
- Assert-Throws {$automationAccount | Get-AzureAutomationSchedule - Name $oneTimeScheName }
337
- $automationAccount | Remove-AzureAutomationSchedule - Name $dailyScheName - Force
338
- Assert-Throws {$automationAccount | Get-AzureAutomationSchedule - Name $dailyScheName }
339
- Remove-AzureAutomationRunbook $accountName - Name $runbook.Name - Force
340
- Assert-Throws {Get-AzureAutomationRunbook $accountName - Name $runbook.Name }
335
+ Remove-AzureRmAutomationSchedule $accountName - Name $oneTimeScheName - Force
336
+ Assert-Throws {$automationAccount | Get-AzureRmAutomationSchedule - Name $oneTimeScheName }
337
+ $automationAccount | Remove-AzureRmAutomationSchedule - Name $dailyScheName - Force
338
+ Assert-Throws {$automationAccount | Get-AzureRmAutomationSchedule - Name $dailyScheName }
339
+ Remove-AzureRmAutomationRunbook $accountName - Name $runbook.Name - Force
340
+ Assert-Throws {Get-AzureRmAutomationRunbook $accountName - Name $runbook.Name }
341
341
}
342
342
343
343
<#
@@ -356,8 +356,8 @@ function Test-AutomationStartUnpublishedRunbook
356
356
Assert-NotNull $runbook " runBook $runbookPath does not import successfully."
357
357
Assert-NotNull $runbook.Tags " Tags of the runbook shouldn't be Null."
358
358
Assert-NotNull $runbook.Description " Description of the runbook shouldn't be Null."
359
- Assert-Throws {Start-AzureAutomationRunbook $accountName - Name $runbook.Name - Parameters $runbookParameters - PassThru - ErrorAction Stop}
359
+ Assert-Throws {Start-AzureRmAutomationRunbook $accountName - Name $runbook.Name - Parameters $runbookParameters - PassThru - ErrorAction Stop}
360
360
361
- Remove-AzureAutomationRunbook $accountName - Name $runbook.Name - Force
362
- Assert-Throws {Get-AzureAutomationRunbook $accountName - Name $runbook.Name - Parameters $runbookParameters - PassThru - ErrorAction Stop}
361
+ Remove-AzureRmAutomationRunbook $accountName - Name $runbook.Name - Force
362
+ Assert-Throws {Get-AzureRmAutomationRunbook $accountName - Name $runbook.Name - Parameters $runbookParameters - PassThru - ErrorAction Stop}
363
363
}
0 commit comments