@@ -154,10 +154,7 @@ private string GetExtensionStatusMessage(OSType currentOSType, bool returnSubsta
154
154
( context . Statuses . Count < 1 ) ||
155
155
( string . IsNullOrWhiteSpace ( context . Statuses [ 0 ] . Message ) ) )
156
156
{
157
- ThrowTerminatingError ( new ErrorRecord ( new ApplicationFailedException ( string . Format ( CultureInfo . CurrentUICulture , "Invalid extension status" ) ) ,
158
- "InvalidResult" ,
159
- ErrorCategory . InvalidResult ,
160
- null ) ) ;
157
+ throw new KeyNotFoundException ( string . Format ( CultureInfo . CurrentUICulture , "Invalid extension status" ) ) ;
161
158
}
162
159
163
160
if ( returnSubstatusMessage )
@@ -351,17 +348,27 @@ public override void ExecuteCmdlet()
351
348
DiskEncryptionSettings osVolumeEncryptionSettings = GetOsVolumeEncryptionSettings ( vmParameters ) ;
352
349
EncryptionStatus dataVolumesEncrypted = AreDataVolumesEncrypted ( vmParameters ) ;
353
350
AzureDiskEncryptionStatusContext encryptionStatus = null ;
351
+ string progressMessage = null ;
354
352
355
353
OSType osType = GetOSType ( vmParameters ) ;
356
354
switch ( osType )
357
355
{
358
356
case OSType . Windows :
357
+ try
358
+ {
359
+ progressMessage = GetExtensionStatusMessage ( osType ) ;
360
+ }
361
+ catch ( KeyNotFoundException )
362
+ {
363
+ progressMessage = string . Format ( CultureInfo . CurrentUICulture , "Extension status not available on the VM" ) ;
364
+ }
365
+
359
366
encryptionStatus = new AzureDiskEncryptionStatusContext
360
367
{
361
368
OsVolumeEncrypted = osVolumeEncrypted ,
362
369
DataVolumesEncrypted = dataVolumesEncrypted ,
363
370
OsVolumeEncryptionSettings = osVolumeEncryptionSettings ,
364
- ProgressMessage = GetExtensionStatusMessage ( osType )
371
+ ProgressMessage = progressMessage
365
372
} ;
366
373
WriteObject ( encryptionStatus ) ;
367
374
break ;
@@ -391,12 +398,21 @@ public override void ExecuteCmdlet()
391
398
} ;
392
399
}
393
400
401
+ try
402
+ {
403
+ progressMessage = GetExtensionStatusMessage ( osType ) ;
404
+ }
405
+ catch ( KeyNotFoundException )
406
+ {
407
+ progressMessage = string . Format ( CultureInfo . CurrentUICulture , "Extension status not available on the VM" ) ;
408
+ }
409
+
394
410
encryptionStatus = new AzureDiskEncryptionStatusContext
395
411
{
396
412
OsVolumeEncrypted = ( EncryptionStatus ) Enum . Parse ( typeof ( EncryptionStatus ) , encryptionStatusParsed [ AzureDiskEncryptionExtensionConstants . encryptionResultOsKey ] ) ,
397
413
DataVolumesEncrypted = ( EncryptionStatus ) Enum . Parse ( typeof ( EncryptionStatus ) , encryptionStatusParsed [ AzureDiskEncryptionExtensionConstants . encryptionResultDataKey ] ) ,
398
414
OsVolumeEncryptionSettings = osVolumeEncryptionSettings ,
399
- ProgressMessage = GetExtensionStatusMessage ( osType )
415
+ ProgressMessage = progressMessage
400
416
} ;
401
417
WriteObject ( encryptionStatus ) ;
402
418
break ;
0 commit comments