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

41 lines
1.2 KiB
PowerShell
Raw Normal View History

2021-06-28 17:23:52 +02:00
# Bootstrap script to init Hyper-v
echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman"
echo "GPLv3"
### Define variables
$scripts_path = Read-host "Scripts path?"
$vhd_path = Read-host "VHD path?"
$vm_path = Read-Host "VM path?"
$source_path = Read-host "Actual source path?"
$base_srv = Read-Host "SRV base disk name without extension?"
$base_cli = Read-Host "CLI base disk name without extension?"
### Store them as ENV vars
$env:SCRIPTS_PATH = ${scripts_path}
$env:VHD_PATH = ${vhd_path}
$env:VM_PATH = ${vm_path}
$env:SOURCE_PATH = ${source_path}
$env:BASE_SRV = ${base_srv}
$env:BASE_CLI = ${base_cli}
### 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}.vhdx -Path ${vhd_path}\Base\Base_SRV_diff.vhdx -Differencing
New-VHD -ParentPath ${vhd_path}\source\${base_cli}.vhdx -Path ${vhd_path}\Base_CLI_diff.vhdx -Differencing
2021-06-28 16:11:41 +02:00
### 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