|
|
|
@ -5,184 +5,223 @@ echo "GPLv3"
|
|
|
|
|
|
|
|
|
|
### Considered as finished. Need improvement VM side.
|
|
|
|
|
|
|
|
|
|
### Define vars
|
|
|
|
|
|
|
|
|
|
$scripts_path = d:\scripts
|
|
|
|
|
|
|
|
|
|
### Adding SRV-01
|
|
|
|
|
|
|
|
|
|
echo "Adding and configuring SRV-01"
|
|
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-01.vhdx
|
|
|
|
|
$vm_name = "SRV-01"
|
|
|
|
|
$switch_name = "Arc-SRV"
|
|
|
|
|
$gen = 2
|
|
|
|
|
$mem = 1024MB
|
|
|
|
|
$min_mem = 512MB
|
|
|
|
|
$mac_mem = 2048MB
|
|
|
|
|
$cpus = 2
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path "d:\VHD\SRV-01.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
echo "Adding and configuring ${vm_name}"
|
|
|
|
|
cp "${env:BASE_VHD_PATH}${env:BASE_SRV_NAME}" "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path ${env:VHD_PATH}${vm_name}.VHDx -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
$DriveLetter = $Lettre.DriveLetter
|
|
|
|
|
$drive = $DriveLetter + ":"
|
|
|
|
|
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}Unattend\FullUnattend-srv.xml" -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}deploy.cmd" -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
mkdir "${Driveletter}:\Tools\Scripts"
|
|
|
|
|
Copy-item ${scripts_path}\Guests\SRV-01.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
Copy-item "${env:SCRIPTS_PATH}Guests\${vm_name}.ps1" "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
|
|
|
|
|
Dismount-VHD d:\VHD\SRV-01.vhdx
|
|
|
|
|
Dismount-VHD "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$vms = @{
|
|
|
|
|
|
|
|
|
|
Name = "SRV-01"
|
|
|
|
|
Generation = '2'
|
|
|
|
|
MemoryStartupBytes = 1024Mb
|
|
|
|
|
VHDPath = "d:\VHD\SRV-01.vhdx"
|
|
|
|
|
SwitchName = "Arc-SRV"
|
|
|
|
|
Name = "$vm_name"
|
|
|
|
|
Generation = "$gen"
|
|
|
|
|
MemoryStartupBytes = "$mem"
|
|
|
|
|
VHDPath = "$env:BASE_VHD_PATH$vm_name.vhdx"
|
|
|
|
|
SwitchName = "$swith_name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
New-VM @vms
|
|
|
|
|
Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
|
Set-VM -Name SRV-01 -ProcessorCount 2
|
|
|
|
|
|
|
|
|
|
Set-VMMemory "${vm_name}" -DynamicMemoryEnabled "$true" -MinimumBytes "${min_mem}" -StartupBytes "${mem}" -MaximumBytes "${max_mem}"
|
|
|
|
|
Set-VM -Name "${vm_name}" -ProcessorCount "${cpus}"
|
|
|
|
|
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
|
Rename-VMNetworkAdapter -VMName 'SRV-01' -NewName 'Arc-SRV'
|
|
|
|
|
Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on
|
|
|
|
|
Rename-VMNetworkAdapter -VMName '${vm_name}' -NewName '${switch_name}'
|
|
|
|
|
Set-VMNetworkAdapter -VMName '${vm_name}' -Name "${switch_name}" -DeviceNaming on
|
|
|
|
|
|
|
|
|
|
### Adding SRV-03
|
|
|
|
|
|
|
|
|
|
echo "Adding and configuring SRV-03"
|
|
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-03.vhdx
|
|
|
|
|
$vm_name = "SRV-01"
|
|
|
|
|
$switch_name = "Arc-SRV"
|
|
|
|
|
$gen = 2
|
|
|
|
|
$mem = 1024MB
|
|
|
|
|
$min_mem = 512MB
|
|
|
|
|
$mac_mem = 2048MB
|
|
|
|
|
$cpus = 2
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path "d:\VHD\SRV-03.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
echo "Adding and configuring ${vm_name}"
|
|
|
|
|
cp "${env:BASE_VHD_PATH}${env:BASE_SRV_NAMEV}" "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path ${env:VHD_PATH}${vm_name}.VHDx -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
$DriveLetter = $Lettre.DriveLetter
|
|
|
|
|
$drive = $DriveLetter + ":"
|
|
|
|
|
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}Unattend\FullUnattend-srv.xml" -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}deploy.cmd" -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
mkdir "${Driveletter}:\Tools\Scripts"
|
|
|
|
|
Copy-item ${scripts_path}\Guests\SRV-03.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
Copy-item "${env:SCRIPTS_PATH}Guests\${vm_name}.ps1" "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
|
|
|
|
|
Dismount-VHD d:\VHD\SRV-03.vhdx
|
|
|
|
|
Dismount-VHD "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$vms = @{
|
|
|
|
|
$vms = {
|
|
|
|
|
|
|
|
|
|
Name = "SRV-03"
|
|
|
|
|
Generation = '2'
|
|
|
|
|
MemoryStartupBytes = 1024Mb
|
|
|
|
|
VHDPath = "d:\VHD\SRV-03.vhdx"
|
|
|
|
|
SwitchName = "Bou-LAN"
|
|
|
|
|
Name = "${vm_name}"
|
|
|
|
|
Generation = "${gen}"
|
|
|
|
|
MemoryStartupBytes = "${mem}"
|
|
|
|
|
VHDPath = "${env:BASE_VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
SwitchName = "${swith_name}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
New-VM @vms
|
|
|
|
|
Set-VMMemory SRV-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
|
Set-VM -Name SRV-03 -ProcessorCount 2
|
|
|
|
|
Set-VMMemory "${vm_name}" -DynamicMemoryEnabled "$true" -MinimumBytes "${min_mem}" -StartupBytes "${mem}" -MaximumBytes "${max_mem}"
|
|
|
|
|
Set-VM -Name "${vm_name}" -ProcessorCount "${cpus}"
|
|
|
|
|
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
|
|
|
|
|
|
Rename-VMNetworkAdapter -VMName 'SRV-03' -NewName 'Bou-LAN'
|
|
|
|
|
Set-VMNetworkAdapter -VMName 'SRV-03' -Name "Bou-Lan" -DeviceNaming on
|
|
|
|
|
|
|
|
|
|
Rename-VMNetworkAdapter -VMName '${vm_name}' -NewName '${switch_name}'
|
|
|
|
|
Set-VMNetworkAdapter -VMName '${vm_name}' -Name "${switch_name}" -DeviceNaming on
|
|
|
|
|
|
|
|
|
|
### Adding and configuring RTR-01
|
|
|
|
|
|
|
|
|
|
echo "Adding and configuring RTR-01"
|
|
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-01.vhdx
|
|
|
|
|
$vm_name = "RTR-01"
|
|
|
|
|
$switch_name = "Arc-CLI"
|
|
|
|
|
$gen = 2
|
|
|
|
|
$mem = 1024MB
|
|
|
|
|
$min_mem = 512MB
|
|
|
|
|
$mac_mem = 2048MB
|
|
|
|
|
$cpus = 2
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path "d:\VHD\RTR-01.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
echo "Adding and configuring ${vm_name}"
|
|
|
|
|
cp "${env:BASE_VHD_PATH}${env:BASE_SRV_NAME}" "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path ${env:VHD_PATH}${vm_name}.VHDx -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
$DriveLetter = $Lettre.DriveLetter
|
|
|
|
|
$drive = $DriveLetter + ":"
|
|
|
|
|
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}Unattend\FullUnattend-srv.xml" -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}deploy.cmd" -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
mkdir "${Driveletter}:\Tools\Scripts"
|
|
|
|
|
Copy-item ${scripts_path}\Guests\RTR-01.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
Copy-item "${env:SCRIPTS_PATH}Guests\${vm_name}.ps1" "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
|
|
|
|
|
Dismount-VHD d:\VHD\RTR-01.vhdx
|
|
|
|
|
Dismount-VHD "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$vms = @{
|
|
|
|
|
$vms = {
|
|
|
|
|
|
|
|
|
|
Name = "RTR-01"
|
|
|
|
|
Generation = '2'
|
|
|
|
|
MemoryStartupBytes = 1024Mb
|
|
|
|
|
VHDPath = "d:\VHD\RTR-01.vhdx"
|
|
|
|
|
SwitchName = "Arc-SRV"
|
|
|
|
|
Name = "${vm_name}"
|
|
|
|
|
Generation = "${gen}"
|
|
|
|
|
MemoryStartupBytes = "${mem}"
|
|
|
|
|
VHDPath = "${env:BASE_VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
SwitchName = "${swith_name}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
New-VM @vms
|
|
|
|
|
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
|
Set-VM -Name RTR-01 -ProcessorCount 2
|
|
|
|
|
Set-VMMemory "${vm_name}" -DynamicMemoryEnabled "$true" -MinimumBytes "${min_mem}" -StartupBytes "${mem}" -MaximumBytes "${max_mem}"
|
|
|
|
|
Set-VM -Name "${vm_name}" -ProcessorCount "${cpus}"
|
|
|
|
|
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
|
#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on
|
|
|
|
|
Rename-VMNetworkAdapter -VMName 'RTR-01' -NewName 'Arc-SRV'
|
|
|
|
|
Set-VMNetworkAdapter -VMName 'RTR-01' -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
|
|
|
|
|
|
|
|
|
|
Rename-VMNetworkAdapter -VMName '${vm_name}' -NewName '${switch_name}'
|
|
|
|
|
Set-VMNetworkAdapter -VMName '${vm_name}' -Name "${switch_name}" -DeviceNaming on
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
|
Rename-VMNetworkAdapter -VMName '${vm_name}' -NewName '${switch_name}'
|
|
|
|
|
Set-VMNetworkAdapter -VMName '${vm_name}' -Name "${switch_name}" -DeviceNaming on
|
|
|
|
|
Add-VMNetworkAdapter -VMName "${vm_name}" -SwitchName "${switch_name2}" -Name "Arc-SRV" -DeviceNaming on
|
|
|
|
|
Add-VMNetworkAdapter -VMName "${vm_name}" -SwitchName "$'{switch_name3}" -Name "Bou-LAN" -DeviceNaming on
|
|
|
|
|
|
|
|
|
|
# RTR-02
|
|
|
|
|
|
|
|
|
|
echo "Adding and configuring RTR-02"
|
|
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-02.vhdx
|
|
|
|
|
$vm_name = "RTR-02"
|
|
|
|
|
$switch_name = "Bou-LAN"
|
|
|
|
|
$switch_name2 = "WAN"
|
|
|
|
|
$gen = 2
|
|
|
|
|
$mem = 1024MB
|
|
|
|
|
$min_mem = 512MB
|
|
|
|
|
$max_mem = 2048MB
|
|
|
|
|
$cpus = 2
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path "d:\VHD\RTR-02.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
echo "Adding and configuring ${vm_name}"
|
|
|
|
|
cp "${env:BASE_PATH}${env:BASE_SRV_NAME}" "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path ${env:VHD_PATH}${vm_name}.VHDx -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
$DriveLetter = $Lettre.DriveLetter
|
|
|
|
|
$drive = $DriveLetter + ":"
|
|
|
|
|
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
>>>>>>> parent of ca6ee46 (Feat: Add VNetwork creation)
|
|
|
|
|
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}Unattend\FullUnattend-srv.xml" -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item "${env:SCRIPTS_PATH}deploy.cmd" -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
mkdir "${Driveletter}:\Tools\Scripts"
|
|
|
|
|
Copy-item ${scripts_path}\Guests\RTR-02.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
Copy-item "${env:SCRIPTS_PATH}Guests\${vm_name}.ps1" "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
|
|
|
|
|
Dismount-VHD d:\VHD\RTR-02.vhdx
|
|
|
|
|
Dismount-VHD "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$vms = @{
|
|
|
|
|
$vms = {
|
|
|
|
|
|
|
|
|
|
Name = "RTR-02"
|
|
|
|
|
Generation = '2'
|
|
|
|
|
MemoryStartupBytes = 1024Mb
|
|
|
|
|
VHDPath = "d:\VHD\RTR-02.vhdx"
|
|
|
|
|
SwitchName = "Bou-LAN"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
New-VM @vms
|
|
|
|
|
|
|
|
|
|
Set-VMMemory RTR-02 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
|
Set-VM -Name RTR-02 -ProcessorCount 2
|
|
|
|
|
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
|
Rename-VMNetworkAdapter -VMName 'RTR-02' -NewName 'Bou-Lan'
|
|
|
|
|
Set-VMNetworkAdapter -VMName 'RTR-02' -Name "Bou-LAN" -DeviceNaming on
|
|
|
|
|
Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# RTR-03
|
|
|
|
|
|
|
|
|
|
echo "Adding and configuring RTR-03"
|
|
|
|
|
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-03.vhdx
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path "d:\VHD\RTR-03.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
$DriveLetter = $Lettre.DriveLetter
|
|
|
|
|
$drive = $DriveLetter + ":"
|
|
|
|
|
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
|
|
|
|
|
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
|
|
|
|
|
mkdir "${Driveletter}:\Tools\Scripts"
|
|
|
|
|
Copy-item ${scripts_path}\Guests\RTR-03.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
|
|
|
|
|
|
|
|
|
|
Dismount-VHD d:\VHD\RTR-03.vhdx
|
|
|
|
|
|
|
|
|
|
$vms = @{
|
|
|
|
|
|
|
|
|
|
Name = "RTR-03"
|
|
|
|
|
Generation = '2'
|
|
|
|
|
MemoryStartupBytes = 1024Mb
|
|
|
|
|
VHDPath = "d:\VHD\RTR-03.vhdx"
|
|
|
|
|
SwitchName = "WAN"
|
|
|
|
|
Name = "${vm_name}"
|
|
|
|
|
Generation = "${gen}"
|
|
|
|
|
MemoryStartupBytes = "${mem}"
|
|
|
|
|
VHDPath = "${env:BASE_VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
SwitchName = "${swith_name}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
New-VM @vms
|
|
|
|
|
|
|
|
|
|
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
|
|
|
|
Set-VM -Name RTR-03 -ProcessorCount 2
|
|
|
|
|
Set-VMMemory "${vm_name}" -DynamicMemoryEnabled "$true" -MinimumBytes "${min_mem}" -StartupBytes "${mem}" -MaximumBytes "${max_mem}"
|
|
|
|
|
Set-VM -Name "${vm_name}" -ProcessorCount "${cpus}"
|
|
|
|
|
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
|
Rename-VMNetworkAdapter -VMName 'RTR-03' -NewName 'WAN'
|
|
|
|
|
Set-VMNetworkAdapter -VMName 'RTR-03' -Name "WAN" -DeviceNaming on
|
|
|
|
|
Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "Aston" -Name "Aston" -DeviceNaming on
|
|
|
|
|
Rename-VMNetworkAdapter -VMName '${vm_name}' -NewName '${switch_name}'
|
|
|
|
|
Set-VMNetworkAdapter -VMName '${vm_name}' -Name "${switch_name}" -DeviceNaming on
|
|
|
|
|
Add-VMNetworkAdapter -VMName "${vm_name}" -SwitchName "${switch_name2}" -Name "${switch_name2}" -DeviceNaming on
|
|
|
|
|
|
|
|
|
|
# RTR-03
|
|
|
|
|
|
|
|
|
|
$vm_name = "RTR-03"
|
|
|
|
|
$switch_name = "Aston"
|
|
|
|
|
$switch_name3 = "WAN"
|
|
|
|
|
$gen = 2
|
|
|
|
|
$mem = 1024MB
|
|
|
|
|
$min_mem = 512MB
|
|
|
|
|
$max_mem = 2048MB
|
|
|
|
|
$cpus = 2
|
|
|
|
|
|
|
|
|
|
echo "Adding and configuring ${vm_name}"
|
|
|
|
|
cp "${env:SOURCE_PATH}${env:BASE_SRV_NAME}" "${env:VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
|
|
|
|
|
$Lettre = Mount-VHD -Path "${env:VHD_PATH}${vm_name}.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
|
|
|
|
|
$DriveLetter = $Lettre.DriveLetter
|
|
|
|
|
$drive = $DriveLetter + ":"
|
|
|
|
|
New-Item -Path ${Driveletter}:\conf\ -Name "Base" -ItemType "directory"
|
|
|
|
|
Copy-Item ${env:SCRIPTS_PATH}Unattend\FullUnattend-srv.xml -Destination $Drive\Windows\Panther\Unattend.xml
|
|
|
|
|
Copy-Item ${env:SCRIPTS_PATH}deploy.cmd -Destination ${Driveletter}:\conf\deploy.cmd
|
|
|
|
|
mkdir ${Driveletter}:\Tools\Scripts
|
|
|
|
|
Copy-item ${env:SCRIPTS_PATH}Guests\${vm_name}.ps1 ${Driveletter}:\Tools\scripts\boot.ps1
|
|
|
|
|
|
|
|
|
|
Dismount-VHD ${env:VHD_PATH}${vm_name}.vhdx
|
|
|
|
|
|
|
|
|
|
$vms = {
|
|
|
|
|
|
|
|
|
|
Name = "${vm_name}"
|
|
|
|
|
Generation = "${gen}"
|
|
|
|
|
MemoryStartupBytes = "${mem}"
|
|
|
|
|
VHDPath = "${env:BASE_VHD_PATH}${vm_name}.vhdx"
|
|
|
|
|
SwitchName = "${swith_name}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
New-VM @vms
|
|
|
|
|
Set-VMMemory "${vm_name}" -DynamicMemoryEnabled "$true" -MinimumBytes "${min_mem}" -StartupBytes "${mem}" -MaximumBytes "${max_mem}"
|
|
|
|
|
Set-VM -Name "${vm_name}" -ProcessorCount "${cpus}"
|
|
|
|
|
|
|
|
|
|
echo "Configuring adapters"
|
|
|
|
|
Rename-VMNetworkAdapter -VMName '${vm_name}' -NewName '${switch_name}'
|
|
|
|
|
Set-VMNetworkAdapter -VMName '${vm_name}' -Name "${switch_name}" -DeviceNaming on
|
|
|
|
|
Add-VMNetworkAdapter -VMName "${vm_name}" -SwitchName "${switch_name2}" -Name "${switch_name2}" -DeviceNaming on
|
|
|
|
|
|
|
|
|
|
### Starting VMS
|
|
|
|
|
|
|
|
|
|
echo "Starting VMs"
|
|
|
|
|
Start-VM -Name RTR*
|
|
|
|
|
|
|
|
|
|