Created
January 14, 2019 14:50
-
-
Save andikrueger/ac789a83f26c7cc1ec2b61302f69a280 to your computer and use it in GitHub Desktop.
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