Aston-HyperV-Code/Host/Bootstrap-Hyper-V.ps1

50 lines
1.7 KiB
PowerShell

# Bootstrap script to init Hyper-v
echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman"
echo "GPLv3"
### Define variables
$base_cli = Read-Host "CLI base disk name with extension?"
$base_srv = Read-Host "SRV base disk name with extension?"
$base_vhd_path = "${vhd_path}Base\"
$scripts_path = Read-host "Scripts path with trailling slash?"
$soft_path = Read "Software path with trailling slash?"
$source_cli_name = Read-Host "CLI source disk name with extension?"
$source_path = Read-host "Actual source path with trailling slash?"
$source_srv_name = Read-Host "SRV source disk name with extension?"
$vhd_path = Read-host "VHD path with trailling slash?"
$vm_path = Read-Host "VM path with trailling slash?"
### Store them as ENV vars
$env:BASE_CLI_NAME = ${base_cli}
$env:BASE_SRV_NAME = ${base_srv}
$env:BASE_VHD_PATH = ${base_vhd_path}
$env:FULL_PATH = ${full_path}
$env:SCRIPTS_PATH = ${scripts_path}
$env:SOFT_PATH = ${soft_path}
$env:SOURCE_CLI_NAME = ${source_cli_name}
$env:SOURCE_PATH = ${source_path}
$env:SOURCE_SRV_NAME = ${source_srv_name}
$env:VM_PATH = ${vm_path}
$env:VHD_PATH = ${vhd_path}
### Let the fuckery begins!
md ${vhd_path}
md ${vhdpath}\Base
md ${vm_path}
Move-Item ${source_path} ${vhd_path}
New-VHD -ParentPath ${vhd_path}\source\${base_srv_name}.vhdx -Path ${vhd_path}\Base\${base_srv_name}.vhdx -Differencing
New-VHD -ParentPath ${vhd_path}\source\${source_cli_name}.vhdx -Path ${vhd_path}\${base_cli_name}.vhdx -Differencing
### Create VMNetworks
New-VMSwitch -name Arc-CLI -SwitchType Private
New-VMSwitch -name Arc-SRV -SwitchType Private
New-VMSwitch -name Bou-LAN -SwitchType Private
New-VMSwitch -name WAN -SwitchType Private
New-VMSwitch -name Aston -NetAdapterName Ethernet -AllowManagementOS $true