File tree 4 files changed +38
-7
lines changed
4 files changed +38
-7
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ function Get-AzMigrateLocalServerReplication {
147
147
if ($parameterSet -eq ' GetBySDSID' ) {
148
148
$machineIdArray = $DiscoveredMachineId.Split (" /" )
149
149
if ($machineIdArray.Length -lt 11 ) {
150
- throw " Invalid machine ID '$DiscoveredMachineId '"
150
+ throw " Invalid machine ARM ID '$DiscoveredMachineId '"
151
151
}
152
152
$siteType = $machineIdArray [7 ]
153
153
$siteName = $machineIdArray [8 ]
Original file line number Diff line number Diff line change @@ -208,9 +208,35 @@ function InvokeAzMigrateGetCommandWithRetries {
208
208
)
209
209
210
210
process {
211
+ # Filter out ErrorAction and ErrorVariable from the parameters
212
+ $params = @ {}
213
+ foreach ($key in $Parameters.Keys ) {
214
+ if ($key -ne " ErrorAction" -and $key -ne " ErrorVariable" ) {
215
+ $params [$key ] = $Parameters [$key ]
216
+ }
217
+ }
218
+
219
+ # Extract user-specified ErrorAction and ErrorVariable or defaults
220
+ # but do not include them in $params
221
+ if ($Parameters.ContainsKey (" ErrorVariable" )) {
222
+ $errorVariable = $Parameters [" ErrorVariable" ]
223
+ }
224
+ else
225
+ {
226
+ $errorVariable = " notPresent"
227
+ }
228
+
229
+ if ($Parameters.ContainsKey (" ErrorAction" )) {
230
+ $errorAction = $Parameters [" ErrorAction" ]
231
+ }
232
+ else
233
+ {
234
+ $errorAction = " Continue"
235
+ }
236
+
211
237
for ($i = 0 ; $i -le $MaxRetryCount ; $i ++ ) {
212
238
try {
213
- $result = & $CommandName @Parameters - ErrorVariable notPresent - ErrorAction SilentlyContinue
239
+ $result = & $CommandName @params - ErrorVariable $errorVariable - ErrorAction $errorAction
214
240
215
241
if ($null -eq $result ) {
216
242
throw $ErrorMessage
@@ -223,14 +249,15 @@ function InvokeAzMigrateGetCommandWithRetries {
223
249
Start-Sleep - Seconds $RetryDelayInSeconds
224
250
}
225
251
else {
226
- throw $ErrorMessage
252
+ throw " Get command failed after $MaxRetryCount retries. Error: $ ( $_ .Exception ) "
227
253
}
228
254
}
229
255
}
230
256
231
257
return $result
232
258
}
233
259
}
260
+
234
261
function ValidateReplication {
235
262
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.DoNotExportAttribute ()]
236
263
param (
Original file line number Diff line number Diff line change @@ -188,19 +188,22 @@ function New-AzMigrateLocalServerReplication {
188
188
$null = $PSBoundParameters.Remove (' Confirm' )
189
189
190
190
$MachineIdArray = $MachineId.Split (" /" )
191
+ if ($MachineIdArray.Length -lt 11 ) {
192
+ throw " Invalid machine ARM ID '$MachineId '"
193
+ }
191
194
$SiteType = $MachineIdArray [7 ]
192
195
$SiteName = $MachineIdArray [8 ]
193
196
$ResourceGroupName = $MachineIdArray [4 ]
194
197
$MachineName = $MachineIdArray [10 ]
195
-
196
- if (($SiteType -ne $SiteTypes.HyperVSites ) -and ($SiteType -ne $SiteTypes.VMwareSites )) {
197
- throw " Site type is not supported. Site type '$SiteType '. Check MachineId provided."
198
- }
199
198
200
199
# Get the source site and the discovered machine
201
200
$null = $PSBoundParameters.Add (" ResourceGroupName" , $ResourceGroupName )
202
201
$null = $PSBoundParameters.Add (" SiteName" , $SiteName )
203
202
$null = $PSBoundParameters.Add (" MachineName" , $MachineName )
203
+
204
+ if (($SiteType -ne $SiteTypes.HyperVSites ) -and ($SiteType -ne $SiteTypes.VMwareSites )) {
205
+ throw " Site type is not supported. Site type '$SiteType '. Check MachineId provided."
206
+ }
204
207
205
208
if ($SiteType -eq $SiteTypes.HyperVSites ) {
206
209
$instanceType = $AzLocalInstanceTypes.HyperVToAzLocal
Original file line number Diff line number Diff line change 19
19
-->
20
20
## Upcoming Release
21
21
* Implemented the Get-AzMigrateServerMigrationStatus cmdlet to retrieve the replication status of servers in Azure Migrate.
22
+ * Fixed bugs in ` New-AzMigrateLocalServerReplication ` that caused HyperVSite or VMwareSite not found.
22
23
23
24
## Version 2.7.1
24
25
You can’t perform that action at this time.
0 commit comments