Skip to content

Commit 1358c04

Browse files
committed
Changed message in case of error
1 parent 68a69c1 commit 1358c04

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

internal/scripts/preimport.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,26 @@ $osDetails = Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Desc
1818

1919
# Check which version of windows we're dealing with
2020
if ($osDetails.Caption -notin $supportedVersions ) {
21-
if($osDetails.Caption -like '*Windows 7*'){
22-
Stop-PSFFunction -Message "Module can not work on Windows 7" -Target $OSDetails -FunctionName 'Pre Import'
21+
if ($osDetails.Caption -like '*Windows 7*') {
22+
Stop-PSFFunction -Message "Module can not work on Windows 7" -Target $OSDetails -FunctionName 'Pre Import'
2323
}
2424
elseif ($osDetails.Caption -like '*Windows 10*') {
25+
$feature = Get-WindowsOptionalFeature -FeatureName 'Microsoft-Hyper-V-All' -Online
26+
if ($feature.State -ne "Enabled") {
27+
Write-PSFMessage -Message "Hyper-V is not enabled, the module can only be used remotely.`nTo use the module locally execute the following command: `"Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All`"" -Level Warning -FunctionName 'Test-PSDCConfiguration'
28+
}
29+
2530
Stop-PSFFunction -Message "Module can only work on Windows 10 Pro, Enterprise or Education" -Target $OSDetails -FunctionName 'Pre Import'
2631
}
2732
elseif ($osDetails.Caption -like '*Windows Server*') {
33+
$feature = Get-WindowsFeature -Name 'Hyper-V'
34+
if (-not $feature.Installed) {
35+
Write-PSFMessage -Message "Hyper-V is not enabled, the module can only be used remotely.`nTo use the module locally execute the following command: `"Install-WindowsFeature -Name Hyper-V`"" -Level Warning -FunctionName 'Test-PSDCConfiguration'
36+
}
37+
2838
Stop-PSFFunction -Message "Module can only work on Windows Server 2012 R2 and up, Enterprise or Education" -Target $OSDetails -FunctionName 'Pre Import'
2939
}
30-
else{
40+
else {
3141
Stop-PSFFunction -Message "Unsupported version of Windows." -Target $OSDetails -FunctionName 'Pre Import'
3242
}
3343
}

0 commit comments

Comments
 (0)