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
|
|
|
|
|
2021-06-30 10:51:47 +02:00
|
|
|
$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-29 10:37:48 +02:00
|
|
|
$scripts_path = Read-host "Scripts path with trailling slash?"
|
2021-06-30 10:51:47 +02:00
|
|
|
$source_cli_name = Read-Host "CLI source disk name with extension?"
|
2021-06-29 10:37:48 +02:00
|
|
|
$source_path = Read-host "Actual source path with trailling slash?"
|
|
|
|
$source_srv_name = Read-Host "SRV source disk name with extension?"
|
2021-06-30 10:51:47 +02:00
|
|
|
$vhd_path = Read-host "VHD path with trailling slash?"
|
|
|
|
$vm_path = Read-Host "VM path with trailling slash?"
|
2021-06-28 17:23:52 +02:00
|
|
|
|
|
|
|
### Store them as ENV vars
|
|
|
|
|
2021-06-30 10:51:47 +02:00
|
|
|
$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}
|
2021-06-30 10:51:47 +02:00
|
|
|
$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}
|
2021-06-30 10:51:47 +02:00
|
|
|
$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
|