Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
916 B
PowerShell
25 lines
916 B
PowerShell
# Install Hyper-V Host Role
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "=========================================" -ForegroundColor Cyan
|
|
Write-Host "Hyper-V Host Role Installation" -ForegroundColor Cyan
|
|
Write-Host "=========================================" -ForegroundColor Cyan
|
|
|
|
# Check if running as Administrator
|
|
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
|
Write-Host "This script requires Administrator privileges." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "`nInstalling Hyper-V role..." -ForegroundColor Yellow
|
|
try {
|
|
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
|
|
Write-Host "Hyper-V installed successfully. System will restart." -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "Error installing Hyper-V: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|