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

49 lines
1.7 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
$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\"
2021-06-30 16:40:57 +02:00
$soft_path = Read-host "Software directory with trailing slash?"
$scripts_path = Read-host "Scripts path with trailing slash?"
$source_cli_name = Read-Host "CLI source disk name with extension?"
2021-06-30 16:40:57 +02:00
$source_path = Read-host "Actual source path with trailing slash?"
2021-06-29 10:37:48 +02:00
$source_srv_name = Read-Host "SRV source disk name with extension?"
2021-06-30 16:40:57 +02:00
$vhd_path = Read-host "VHD path with trailing slash?"
$vm_path = Read-Host "VM path with trailing slash?"
2021-06-28 17:23:52 +02:00
### 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}
2021-06-28 17:23:52 +02:00
$env:SCRIPTS_PATH = ${scripts_path}
$env:SOURCE_CLI_NAME = ${source_cli_name}
2021-06-28 17:23:52 +02:00
$env:SOURCE_PATH = ${source_path}
2021-06-29 10:37:48 +02:00
$env:SOURCE_SRV_NAME = ${source_srv_name}
$env:VM_PATH = ${vm_path}
$env:VHD_PATH = ${vhd_path}
2021-06-28 17:23:52 +02:00
### Let the fuckery begins!
md ${vhd_path}
md ${vhdpath}\Base
md ${vm_path}
Move-Item ${source_path} ${vhd_path}
2021-06-29 10:37:48 +02:00
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
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