106 lines
3.0 KiB
PowerShell
106 lines
3.0 KiB
PowerShell
## Tool to automate VM creation
|
|
echo "Shamefully made by Alexandre Simao. Such a waste of time.`
|
|
Pardon-me dear M. Stallman"
|
|
echo "CC BY-NC-SA 4.0"
|
|
# TODO: SRV-01, RTR-02, RTR-03
|
|
# Done: RTR-01 Full auto
|
|
|
|
# Region SRV-01
|
|
|
|
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\SRV-01.vhdx
|
|
|
|
Mount-VHD d:\VHD\SRV-01.vhdx
|
|
Copy-Item d:\Unattend\SRV-01.xml -Destination e:\Windows\Panther\Unattend.xml
|
|
Dismount-VHD d:\VHD\SRV-01.vhdx
|
|
|
|
$vms = @{
|
|
|
|
Name = "SRV-01"
|
|
Generation = '2'
|
|
MemoryStartupBytes = 1024Mb
|
|
VHDPath = "d:\VHD\$VMName.vhdx"
|
|
}
|
|
|
|
New-VM @vms
|
|
Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
$vmadapter = Get-VMNetworkAdapter -VMName "SRV-01"
|
|
Add-VMNetworkAdapter -VMName "SRV-01" -SwitchName "Arc-SRV" -Name "Arc-SRV" -DeviceNaming on
|
|
|
|
# RTR-01
|
|
|
|
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-01.vhdx
|
|
|
|
Mount-VHD d:\VHD\RTR-01.vhdx
|
|
Copy-Item d:\Unattend\RTR-01.xml -Destination e:\Windows\Panther\Unattend.xml
|
|
Dismount-VHD d:\VHD\RTR-01.vhdx
|
|
|
|
$vms = @{
|
|
|
|
Name = "RTR-01"
|
|
Generation = '2'
|
|
MemoryStartupBytes = 1024Mb
|
|
VHDPath = "d:\VHD\RTR-01.vhdx"
|
|
}
|
|
|
|
New-VM @vms
|
|
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-01"
|
|
#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on
|
|
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-CLI" -Name "Arc-Cli" -DeviceNaming on
|
|
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
|
|
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-SRV" -Name "Arc-SRV" -DeviceNaming on
|
|
|
|
# RTR-02
|
|
|
|
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-02.vhdx
|
|
|
|
Mount-VHD d:\VHD\RTR-02.vhdx
|
|
Copy-Item d:\Unattend\RTR-02.xml -Destination e:\Windows\Panther\Unattend.xml
|
|
Dismount-VHD d:\VHD\RTR-02.vhdx
|
|
|
|
$vms = @{
|
|
|
|
Name = "RTR-02"
|
|
Generation = '2'
|
|
MemoryStartupBytes = 1024Mb
|
|
VHDPath = "d:\VHD\$VMName.vhdx"
|
|
}
|
|
|
|
New-VM @vms
|
|
|
|
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-02"
|
|
Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "Bou-LAN" -Name "Bou-LAN" -DeviceNaming on
|
|
Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
|
|
|
|
|
|
# RTR-03
|
|
|
|
|
|
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-03.vhdx
|
|
|
|
Mount-VHD d:\VHD\RTR-03.vhdx
|
|
Copy-Item d:\Unattend\RTR-03.xml -Destination e:\Windows\Panther\Unattend.xml
|
|
Dismount-VHD d:\VHD\RTR-03.vhdx
|
|
|
|
$vms = @{
|
|
|
|
Name = "RTR-03"
|
|
Generation = '2'
|
|
MemoryStartupBytes = 1024Mb
|
|
VHDPath = "d:\VHD\$VMName.vhdx"
|
|
}
|
|
|
|
New-VM @vms
|
|
|
|
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
$vmadapter = Get-VMNetworkAdapter -VMName "RTR-03"
|
|
Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "Aston" -Name "Aston" -DeviceNaming on
|
|
Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
|
|
|
|
|
|
Start-VM -Name RTR*
|
|
Start-VM -Name SRV*
|