Aston-HyperV-Code/Host/Infra-Standard.ps1

100 lines
2.4 KiB
PowerShell
Raw Normal View History

2021-04-20 11:39:24 +02:00
## Tool to automate VM creation
2021-04-20 15:25:09 +02:00
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
# SRV-01
2021-04-20 11:39:24 +02:00
$VMName = "SRV-01"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\$VMName.vhdx
Mount-VHD d:\VHD\$VMName.vhdx
Copy-Item d:\Unattend\$VMName.xml -Destination e:\Windows\Panther\Unattend.xml
Dismount-VHD d:\VHD\$VMName.vhdx
2021-04-20 11:39:24 +02:00
$vms = @{
Name = $VMName
Generation = '2'
MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\$VMName.vhdx"
SwitchName = 'Arc-SRV'
}
New-VM @vms
Set-VMMemory $VMName -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
2021-04-20 15:25:09 +02:00
# RTR-01
2021-04-20 11:39:24 +02:00
$VMName = "RTR-01"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\$VMName.vhdx
Mount-VHD d:\VHD\$VMName.vhdx
Copy-Item d:\Unattend\$VMName.xml -Destination e:\Windows\Panther\Unattend.xml
Dismount-VHD d:\VHD\$VMName.vhdx
2021-04-20 11:39:24 +02:00
$vms = @{
Name = $VMName
Generation = '2'
MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\$VMName.vhdx"
2021-04-20 15:25:09 +02:00
SwitchName = 'Arc-SRV'
2021-04-20 11:39:24 +02:00
}
New-VM @vms
Set-VMMemory $VMName -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
2021-04-20 15:25:09 +02:00
Add-VMNetworkAdapter -VMName $VMName -SwitchName "Arc-CLI"
Add-VMNetworkAdapter -VMName $VMName -SwitchName "WAN"
# RTR-02
2021-04-20 11:39:24 +02:00
$VMName = "RTR-02"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\$VMName.vhdx
Mount-VHD d:\VHD\$VMName.vhdx
Copy-Item d:\Unattend\$VMName.xml -Destination e:\Windows\Panther\Unattend.xml
Dismount-VHD d:\VHD\$VMName.vhdx
2021-04-20 11:39:24 +02:00
$vms = @{
Name = $VMName
Generation = '2'
MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\$VMName.vhdx"
SwitchName = 'Bou-LAN'
}
New-VM @vms
Set-VMMemory $VMName -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
2021-04-20 15:25:09 +02:00
#Add-VMSwitch -Name "WAN" -ResourcePoolName "WAN"
Add-VMNetworkAdapter -VMName $VMName -SwitchName "WAN"
# RTR-03
2021-04-20 11:39:24 +02:00
$VMName = "RTR-03"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\$VMName.vhdx
Mount-VHD d:\VHD\$VMName.vhdx
Copy-Item d:\Unattend\$VMName.xml -Destination e:\Windows\Panther\Unattend.xml
Dismount-VHD d:\VHD\$VMName.vhdx
2021-04-20 11:39:24 +02:00
$vms = @{
Name = $VMName
Generation = '2'
MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\$VMName.vhdx"
SwitchName = 'WAN'
}
New-VM @vms
Set-VMMemory $VMName -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
2021-04-20 15:25:09 +02:00
Add-VMNetworkAdapter -VMName $VMName -SwitchName "Aston"
2021-04-20 11:39:24 +02:00
2021-04-20 15:25:09 +02:00
Start-VM -Name RTR*
Start-VM -Name SRV*