Skip to content

Instantly share code, notes, and snippets.

@andikrueger
Created January 14, 2019 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andikrueger/ac789a83f26c7cc1ec2b61302f69a280 to your computer and use it in GitHub Desktop.
Save andikrueger/ac789a83f26c7cc1ec2b61302f69a280 to your computer and use it in GitHub Desktop.
Script Resource for configuring Hyper-V Role on Windows 10
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