File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -1217,7 +1217,11 @@ function Remove-Lab
1217
1217
{
1218
1218
$machineMetadata = Get-LWHypervVMDescription - ComputerName $machine - ErrorAction SilentlyContinue
1219
1219
$vm = Get-VM - Name $machine - ErrorAction SilentlyContinue
1220
- if ($machineMetadata.LabName -ne $labName -and $vm )
1220
+ if (-not $machineMetadata )
1221
+ {
1222
+ Write-Error - Message " Cannot remove machine '$machine ' because lab meta data could not be retrieved"
1223
+ }
1224
+ elseif ($machineMetadata.LabName -ne $labName -and $vm )
1221
1225
{
1222
1226
Write-Error - Message " Cannot remove machine '$machine ' because it does not belong to this lab"
1223
1227
}
Original file line number Diff line number Diff line change @@ -1684,10 +1684,16 @@ function Get-LWHypervVMDescription
1684
1684
1685
1685
$type = Get-Type - GenericType AutomatedLab.DictionaryXmlStore - T String, String
1686
1686
1687
- $importMethodInfo = $type.GetMethod (' ImportFromString' , [System.Reflection.BindingFlags ]::Public -bor [System.Reflection.BindingFlags ]::Static )
1688
- $dictionary = $importMethodInfo.Invoke ($null , $vm.Notes )
1689
-
1690
- $dictionary
1687
+ try
1688
+ {
1689
+ $importMethodInfo = $type.GetMethod (' ImportFromString' , [System.Reflection.BindingFlags ]::Public -bor [System.Reflection.BindingFlags ]::Static )
1690
+ $dictionary = $importMethodInfo.Invoke ($null , $vm.Notes )
1691
+ $dictionary
1692
+ }
1693
+ catch
1694
+ {
1695
+ Write-ScreenInfo - Message " The notes field of the virtual machine '$ComputerName ' could not be read as XML" - Type Warning
1696
+ }
1691
1697
1692
1698
Write-LogFunctionExit
1693
1699
}
You can’t perform that action at this time.
0 commit comments