## Tool to automate VM creation echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman" # SRV-01 # TODO: Export Mac/Name to import it on VMS $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 $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 # RTR-01 $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 $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 Add-VMNetworkAdapter -VMName $VMName -SwitchName "Arc-CLI" Add-VMNetworkAdapter -VMName $VMName -SwitchName "WAN"Attends # RTR-02 $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 $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 #Add-VMSwitch -Name "WAN" -ResourcePoolName "WAN" Add-VMNetworkAdapter -VMName $VMName -SwitchName "WAN" # RTR-03 $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 $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 Add-VMNetworkAdapter -VMName $VMName -SwitchName "Aston" $VMName = "SRV-01" $MACSRV01 = (Get-VMNetworkAdapter -VMName SRV-01).MacAddress echo "$MACSRV01" | Out-file -FilePath D:\scripts\Guests\MACS\MAC$VMName.txt $VMName = "RTR-01" $MACRTR01 = (Get-VMNetworkAdapter -VMName RTR-01).MacAddress echo "$MACRTR01" | Out-file -FilePath D:\scripts\Guests\MACS\MAC$VMName.txt $VMName = "RTR-02" $MACRTR02 = (Get-VMNetworkAdapter -VMName RTR-02).MacAddress echo "$MACRTR02" | Out-file -FilePath D:\scripts\Guests\MACS\MAC$VMName.txt $VMName = "RTR-03" $MACRTR03 = (Get-VMNetworkAdapter -VMName RTR-03).MacAddress echo "$MACRTR03" | Out-file -FilePath D:\scripts\Guests\MACS\MAC$VMName.txt Start-VM -Name RTR* Start-VM -Name SRV*