2021-04-20 11:39:24 +02:00
|
|
|
## Tool to automate VM creation
|
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman"
|
|
|
|
echo "GPLv3"
|
2021-04-21 12:16:54 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
### Considered as finished. Need improvement VM side.
|
|
|
|
|
|
|
|
### Adding SRV-01
|
|
|
|
|
|
|
|
echo "Adding and configuring SRV-01"
|
2021-05-10 11:35:41 +02:00
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-01.vhdx
|
2021-04-20 12:50:50 +02:00
|
|
|
|
2021-04-21 12:16:54 +02:00
|
|
|
Mount-VHD d:\VHD\SRV-01.vhdx
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
|
2021-04-23 17:37:49 +02:00
|
|
|
mkdir e:\Tools\Scripts
|
2021-05-12 16:52:54 +02:00
|
|
|
mkdir "e:\Program Files\BGINFO"
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-item d:\Scripts\Guests\SRV-01.ps1 E:\Tools\scripts\boot.ps1
|
2021-05-12 16:52:54 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
|
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
|
2021-05-12 18:01:39 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
|
2021-04-21 12:16:54 +02:00
|
|
|
Dismount-VHD d:\VHD\SRV-01.vhdx
|
2021-04-20 11:39:24 +02:00
|
|
|
|
|
|
|
$vms = @{
|
2021-04-21 12:16:54 +02:00
|
|
|
|
|
|
|
Name = "SRV-01"
|
2021-04-20 11:39:24 +02:00
|
|
|
Generation = '2'
|
|
|
|
MemoryStartupBytes = 1024Mb
|
2021-04-22 15:58:53 +02:00
|
|
|
VHDPath = "d:\VHD\SRV-01.vhdx"
|
2021-04-22 17:26:29 +02:00
|
|
|
SwitchName = "Arc-SRV"
|
2021-04-20 11:39:24 +02:00
|
|
|
}
|
2021-04-21 12:16:54 +02:00
|
|
|
|
2021-04-20 11:39:24 +02:00
|
|
|
New-VM @vms
|
2021-04-21 12:16:54 +02:00
|
|
|
Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
2021-04-22 15:58:53 +02:00
|
|
|
Set-VM -Name SRV-01 -ProcessorCount 2
|
2021-04-23 12:54:01 +02:00
|
|
|
|
|
|
|
echo "Configuring adapters"
|
2021-04-22 17:26:29 +02:00
|
|
|
Rename-VMNetworkAdapter -VMName 'SRV-01' -NewName 'Arc-SRV'
|
|
|
|
Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on
|
2021-04-22 15:58:53 +02:00
|
|
|
|
2021-05-14 10:29:48 +02:00
|
|
|
### Adding SRV-03
|
|
|
|
|
|
|
|
echo "Adding and configuring SRV-03"
|
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-03.vhdx
|
|
|
|
|
|
|
|
Mount-VHD d:\VHD\SRV-03.vhdx
|
|
|
|
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
|
|
|
|
mkdir e:\Tools\Scripts
|
|
|
|
mkdir "e:\Program Files\BGINFO"
|
|
|
|
Copy-item d:\Scripts\Guests\SRV-03.ps1 E:\Tools\scripts\boot.ps1
|
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
|
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
|
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
|
|
|
|
Dismount-VHD d:\VHD\SRV-01.vhdx
|
|
|
|
|
|
|
|
$vms = @{
|
|
|
|
|
|
|
|
Name = "SRV-03"
|
|
|
|
Generation = '2'
|
|
|
|
MemoryStartupBytes = 1024Mb
|
|
|
|
VHDPath = "d:\VHD\SRV-01.vhdx"
|
|
|
|
SwitchName = "Arc-SRV"
|
|
|
|
}
|
|
|
|
|
|
|
|
New-VM @vms
|
|
|
|
Set-VMMemory SRV-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
Set-VM -Name SRV-03 -ProcessorCount 2
|
|
|
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
Rename-VMNetworkAdapter -VMName 'SRV-03' -NewName 'Arc-SRV'
|
|
|
|
Set-VMNetworkAdapter -VMName 'SRV-03' -Name "Arc-SRV" -DeviceNaming on
|
2021-04-20 11:39:24 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
### Adding and configuring RTR-01
|
2021-04-20 15:25:09 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
echo "Adding and configuring RTR-01"
|
2021-05-10 11:35:41 +02:00
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-01.vhdx
|
2021-04-20 12:50:50 +02:00
|
|
|
|
2021-04-21 12:16:54 +02:00
|
|
|
Mount-VHD d:\VHD\RTR-01.vhdx
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
|
2021-04-23 17:37:49 +02:00
|
|
|
mkdir e:\Tools\Scripts
|
2021-05-12 16:52:54 +02:00
|
|
|
mkdir "e:\Program Files\BGINFO"
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-item d:\Scripts\Guests\RTR-01.ps1 E:\Tools\scripts\boot.ps1
|
2021-05-12 16:52:54 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
|
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
|
2021-05-12 18:01:39 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
|
2021-04-21 12:16:54 +02:00
|
|
|
Dismount-VHD d:\VHD\RTR-01.vhdx
|
2021-04-20 11:39:24 +02:00
|
|
|
|
|
|
|
$vms = @{
|
2021-04-21 12:16:54 +02:00
|
|
|
|
|
|
|
Name = "RTR-01"
|
2021-04-20 11:39:24 +02:00
|
|
|
Generation = '2'
|
|
|
|
MemoryStartupBytes = 1024Mb
|
2021-04-21 12:16:54 +02:00
|
|
|
VHDPath = "d:\VHD\RTR-01.vhdx"
|
2021-04-22 17:26:29 +02:00
|
|
|
SwitchName = "Arc-SRV"
|
2021-04-20 11:39:24 +02:00
|
|
|
}
|
2021-04-21 12:16:54 +02:00
|
|
|
|
2021-04-20 11:39:24 +02:00
|
|
|
New-VM @vms
|
2021-04-21 12:16:54 +02:00
|
|
|
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
2021-04-22 15:58:53 +02:00
|
|
|
Set-VM -Name RTR-01 -ProcessorCount 2
|
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
echo "Configuring adapters"
|
2021-04-21 17:59:14 +02:00
|
|
|
#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on
|
2021-04-22 17:26:29 +02:00
|
|
|
Rename-VMNetworkAdapter -VMName 'RTR-01' -NewName 'Arc-SRV'
|
|
|
|
Set-VMNetworkAdapter -VMName 'RTR-01' -Name "Arc-SRV" -DeviceNaming on
|
2021-04-21 17:59:14 +02:00
|
|
|
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "Arc-CLI" -Name "Arc-Cli" -DeviceNaming on
|
|
|
|
Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
|
2021-04-22 17:26:29 +02:00
|
|
|
|
2021-04-20 15:25:09 +02:00
|
|
|
|
|
|
|
# RTR-02
|
2021-04-20 11:39:24 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
echo "Adding and configuring RTR-02"
|
2021-05-10 11:35:41 +02:00
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-02.vhdx
|
2021-04-20 12:50:50 +02:00
|
|
|
|
2021-04-21 12:16:54 +02:00
|
|
|
Mount-VHD d:\VHD\RTR-02.vhdx
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
|
2021-04-23 17:37:49 +02:00
|
|
|
mkdir e:\Tools\Scripts
|
2021-05-12 16:52:54 +02:00
|
|
|
mkdir "e:\Program Files\BGINFO"
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-item D:\scripts\Guests\RTR-02.ps1 E:\Tools\scripts\boot.ps1
|
2021-05-12 16:52:54 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
|
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
|
2021-05-12 18:01:39 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
|
2021-04-21 12:16:54 +02:00
|
|
|
Dismount-VHD d:\VHD\RTR-02.vhdx
|
2021-04-20 11:39:24 +02:00
|
|
|
|
|
|
|
$vms = @{
|
2021-04-21 12:16:54 +02:00
|
|
|
|
|
|
|
Name = "RTR-02"
|
2021-04-20 11:39:24 +02:00
|
|
|
Generation = '2'
|
|
|
|
MemoryStartupBytes = 1024Mb
|
2021-04-22 15:58:53 +02:00
|
|
|
VHDPath = "d:\VHD\RTR-02.vhdx"
|
2021-04-22 17:26:29 +02:00
|
|
|
SwitchName = "Bou-LAN"
|
2021-04-21 12:16:54 +02:00
|
|
|
}
|
|
|
|
|
2021-04-20 11:39:24 +02:00
|
|
|
New-VM @vms
|
2021-04-21 15:00:09 +02:00
|
|
|
|
2021-04-22 15:58:53 +02:00
|
|
|
Set-VMMemory RTR-02 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
Set-VM -Name RTR-02 -ProcessorCount 2
|
2021-04-21 15:00:09 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
echo "Configuring adapters"
|
2021-04-22 17:26:29 +02:00
|
|
|
Rename-VMNetworkAdapter -VMName 'RTR-02' -NewName 'Bou-Lan'
|
|
|
|
Set-VMNetworkAdapter -VMName 'RTR-02' -Name "Bou-LAN" -DeviceNaming on
|
2021-04-22 10:46:50 +02:00
|
|
|
Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
|
2021-04-21 15:00:09 +02:00
|
|
|
|
2021-04-20 15:25:09 +02:00
|
|
|
|
2021-04-22 17:26:29 +02:00
|
|
|
|
2021-04-20 15:25:09 +02:00
|
|
|
# RTR-03
|
2021-04-20 11:39:24 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
echo "Adding and configuring RTR-03"
|
2021-05-10 11:35:41 +02:00
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-03.vhdx
|
2021-04-21 12:16:54 +02:00
|
|
|
|
|
|
|
Mount-VHD d:\VHD\RTR-03.vhdx
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
|
2021-04-23 17:37:49 +02:00
|
|
|
mkdir e:\Tools\Scripts
|
2021-05-12 16:52:54 +02:00
|
|
|
mkdir "e:\Program Files\BGINFO"
|
2021-05-12 16:25:20 +02:00
|
|
|
Copy-item d:\Scripts\Guests\RTR-03.ps1 E:\Tools\scripts\boot.ps1
|
2021-05-12 16:52:54 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
|
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
|
2021-05-12 18:01:39 +02:00
|
|
|
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
|
2021-04-21 12:16:54 +02:00
|
|
|
Dismount-VHD d:\VHD\RTR-03.vhdx
|
2021-04-20 11:39:24 +02:00
|
|
|
|
|
|
|
$vms = @{
|
2021-04-21 12:16:54 +02:00
|
|
|
|
|
|
|
Name = "RTR-03"
|
2021-04-20 11:39:24 +02:00
|
|
|
Generation = '2'
|
|
|
|
MemoryStartupBytes = 1024Mb
|
2021-04-22 15:58:53 +02:00
|
|
|
VHDPath = "d:\VHD\RTR-03.vhdx"
|
2021-04-22 17:26:29 +02:00
|
|
|
SwitchName = "WAN"
|
2021-04-21 12:16:54 +02:00
|
|
|
}
|
2021-04-20 17:28:39 +02:00
|
|
|
|
2021-04-21 12:16:54 +02:00
|
|
|
New-VM @vms
|
2021-04-21 15:00:09 +02:00
|
|
|
|
2021-04-21 12:16:54 +02:00
|
|
|
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
2021-04-22 15:58:53 +02:00
|
|
|
Set-VM -Name RTR-03 -ProcessorCount 2
|
2021-04-21 15:00:09 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
echo "Configuring adapters"
|
2021-04-22 17:26:29 +02:00
|
|
|
Rename-VMNetworkAdapter -VMName 'RTR-03' -NewName 'WAN'
|
|
|
|
Set-VMNetworkAdapter -VMName 'RTR-03' -Name "WAN" -DeviceNaming on
|
2021-04-22 10:46:50 +02:00
|
|
|
Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "Aston" -Name "Aston" -DeviceNaming on
|
2021-04-22 17:26:29 +02:00
|
|
|
|
2021-04-23 12:54:01 +02:00
|
|
|
### Starting VMS
|
|
|
|
echo "Starting VMs"
|
2021-04-20 15:25:09 +02:00
|
|
|
Start-VM -Name RTR*
|
2021-05-10 17:23:11 +02:00
|
|
|
|
2021-05-12 10:48:52 +02:00
|
|
|
### Sleeping 30s
|
2021-05-10 17:28:09 +02:00
|
|
|
|
2021-05-12 10:48:52 +02:00
|
|
|
echo "Sleeping 30"
|
|
|
|
Sleep 30
|
2021-05-10 17:23:11 +02:00
|
|
|
|
2021-04-20 15:25:09 +02:00
|
|
|
Start-VM -Name SRV*
|