Script Resource for configuring Hyper-V Role on Windows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Script Hyper-V | |
{ | |
GetScript = { | |
Write-Verbose "Get current status for Microsoft-Hyper-V Feature" | |
$hyperVFeatureState = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online -ErrorAction SilentlyContinue | |
return @{ | |
Result = $hyperVFeatureState | |
} | |
} | |
SetScript = { | |
Write-Verbose "Activating Microsoft-Hyper-V Feature" | |
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All | |
} | |
TestScript = { | |
Write-Verbose "Test the current status for Microsoft-Hyper-V Feature" | |
$hyperVFeatureState = & ([ScriptBlock]::Create($GetScript)) | |
Write-Verbose "Current status is: $($hyperVFeatureState.Result.State)" | |
return $hyperVFeatureState.Result.State -eq 'Enabled' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment