From 07425d4de618fb5d15f5c0436bd5d33da5c4ca2f Mon Sep 17 00:00:00 2001 From: Alexandre-Simao Date: Wed, 2 Jun 2021 10:12:04 +0200 Subject: [PATCH] Feat: SRV-01 DNS Beta+Diff Kill --- Guests/SRV-01.ps1 | 8 +- Host/{Kill-Client.ps1 => Client-Kill.ps1} | 8 +- Host/{Clients.ps1 => Create-Clients.ps1} | 164 ++++++++++----------- Host/Create-SRV.ps1 | 67 +++++++++ Host/{Serveurs.ps1 => Create-Serveurs.ps1} | 0 Host/SRV-Kill | 3 + Host/{Kill-Serv.ps1 => Serv-Kill.ps1} | 14 +- 7 files changed, 167 insertions(+), 97 deletions(-) rename Host/{Kill-Client.ps1 => Client-Kill.ps1} (93%) rename Host/{Clients.ps1 => Create-Clients.ps1} (97%) create mode 100644 Host/Create-SRV.ps1 rename Host/{Serveurs.ps1 => Create-Serveurs.ps1} (100%) create mode 100644 Host/SRV-Kill rename Host/{Kill-Serv.ps1 => Serv-Kill.ps1} (94%) diff --git a/Guests/SRV-01.ps1 b/Guests/SRV-01.ps1 index 2dc4e51..bc16cae 100644 --- a/Guests/SRV-01.ps1 +++ b/Guests/SRV-01.ps1 @@ -126,12 +126,12 @@ Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 192.168.128.1,192 Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature #Create asrbd.local zone -Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name asrbd.local -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1" +Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name "asrbd.local" -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1" -Add-DnsServerPrimaryZone -ResponsiblePerson "bol@loc.ks" -DynamicUpdate None -ZoneFile asrbd.local.dns -Name asrbd.local +Add-DnsServerPrimaryZone -ResponsiblePerson bol@loc.ks -DynamicUpdate None -ZoneFile asrbd.local.dns -Name asrbd.local #Rename SOA+NS Main Zone -$ns = Get-DnsServerResourceRecord -ZoneName asrbd.local -RRType NS +$ns = Get-DnsServerResourceRecord -ZoneName "asrbd.local" -RRType NS $nsnew = $ns.Clone() @@ -153,7 +153,7 @@ Set-DnsServerResourceRecord -ZoneName asrbd.local -NewInputObject $soanew -OldIn Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name asrbd.local -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1" #Create reverse lookup Zone -Add-DnsServerPrimaryZone -NetworkID "192.168.0.0/24" -Zonefile "168.192.in-addr.arpa.dns" +Add-DnsServerPrimaryZone -NetworkID "192.168.0.0/16" -Zonefile "168.192.in-addr.arpa.dns" #Rename SOA+NS Reverse $ns = Get-DnsServerResourceRecord -ZoneName 168.192.in-addr.arpa -RRType NS diff --git a/Host/Kill-Client.ps1 b/Host/Client-Kill.ps1 similarity index 93% rename from Host/Kill-Client.ps1 rename to Host/Client-Kill.ps1 index 0b93465..a52e247 100644 --- a/Host/Kill-Client.ps1 +++ b/Host/Client-Kill.ps1 @@ -1,4 +1,4 @@ -Stop-VM CLI* -turnoff -Remove-VM CLI* -Force - -del d:\VHD\CLI* +Stop-VM CLI* -turnoff +Remove-VM CLI* -Force + +del d:\VHD\CLI* diff --git a/Host/Clients.ps1 b/Host/Create-Clients.ps1 similarity index 97% rename from Host/Clients.ps1 rename to Host/Create-Clients.ps1 index b7b646b..7c5534f 100644 --- a/Host/Clients.ps1 +++ b/Host/Create-Clients.ps1 @@ -1,82 +1,82 @@ -## Tool to automate VM creation - -echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman" -echo "GPLv3" - -### Considered as finished. Need improvement VM side. - -### Adding CLI-01 - -echo "Adding and configuring CLI-01" -cp D:\VHD\Base\Base_Client_dif.vhdx D:\VHD\CLI-01.vhdx - -Mount-VHD d:\VHD\CLI-01.vhdx -<<<<<<< HEAD -Copy-Item d:\Scripts\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml -======= -Copy-Item d:\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml ->>>>>>> DNS -#mkdir e:\Tools\Scripts -#Copy-item d:\Scripts\Guests\CLI-01.ps1 E:\Tools\scripts -mkdir "f:\Program Files\BGINFO" -Copy-Item d:\Soft\BGInfo_Deploiement\BGInfo.exe "f:\Program Files\BGINFO" -Copy-Item d:\Soft\BGInfo_Deploiement\mescouilles2.bgi "f:\Program Files\BGINFO" -Copy-Item D:\Soft\BGInfo_Deploiement\bginfox86.bat "f:\Users\AdminLocal\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" -Dismount-VHD d:\VHD\CLI-01.vhdx - -$vms = @{ - - Name = "CLI-01" - Generation = '1' - MemoryStartupBytes = 1024Mb - VHDPath = "d:\VHD\CLI-01.vhdx" - SwitchName = "Arc-CLI" -} - -New-VM @vms -Set-VMMemory CLI-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB -Set-VM -Name CLI-01 -ProcessorCount 2 - -echo "Configuring adapters" -Rename-VMNetworkAdapter -VMName 'CLI-01' -NewName 'Arc-CLI' - - -### Adding and configuring CLI-03 - -echo "Adding and configuring CLI-03" -cp D:\VHD\Base\Base_Client_dif.vhdx D:\VHD\CLI-03.vhdx - -Mount-VHD d:\VHD\CLI-03.vhdx -<<<<<<< HEAD -Copy-Item d:\Scripts\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml -======= -Copy-Item d:\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml ->>>>>>> DNS -#mkdir e:\Tools\Scripts -#Copy-item d:\Scripts\Guests\CLI-03.ps1 E:\Tools\scripts -mkdir "f:\Program Files\BGINFO" -Copy-Item d:\Soft\BGInfo_Deploiement\BGInfox86.exe "f:\Program Files\BGINFO" -Copy-Item d:\Soft\BGInfo_Deploiement\mescouilles2.bgi "f:\Program Files\BGINFO" -Copy-Item D:\Soft\BGInfo_Deploiement\bginfox86.bat "f:\Users\AdminLocal\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" -Dismount-VHD d:\VHD\CLI-03.vhdx - -$vms = @{ - - Name = "CLI-03" - Generation = '1' - MemoryStartupBytes = 1024Mb - VHDPath = "d:\VHD\CLI-03.vhdx" - SwitchName = "Bou-LAN" -} - -New-VM @vms -Set-VMMemory CLI-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB -Set-VM -Name CLI-03 -ProcessorCount 2 - -echo "Configuring adapters" -#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Bou-LAN" -DeviceNaming on -Rename-VMNetworkAdapter -VMName 'CLI-03' -NewName 'Bou-LAN' - -### Starting VMS -echo "Starting VMs" -Start-VM -Name CLI* +## Tool to automate VM creation + +echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman" +echo "GPLv3" + +### Considered as finished. Need improvement VM side. + +### Adding CLI-01 + +echo "Adding and configuring CLI-01" +cp D:\VHD\Base\Base_Client_dif.vhdx D:\VHD\CLI-01.vhdx + +Mount-VHD d:\VHD\CLI-01.vhdx +<<<<<<< HEAD +Copy-Item d:\Scripts\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml +======= +Copy-Item d:\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml +>>>>>>> DNS +#mkdir e:\Tools\Scripts +#Copy-item d:\Scripts\Guests\CLI-01.ps1 E:\Tools\scripts +mkdir "f:\Program Files\BGINFO" +Copy-Item d:\Soft\BGInfo_Deploiement\BGInfo.exe "f:\Program Files\BGINFO" +Copy-Item d:\Soft\BGInfo_Deploiement\mescouilles2.bgi "f:\Program Files\BGINFO" +Copy-Item D:\Soft\BGInfo_Deploiement\bginfox86.bat "f:\Users\AdminLocal\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" +Dismount-VHD d:\VHD\CLI-01.vhdx + +$vms = @{ + + Name = "CLI-01" + Generation = '1' + MemoryStartupBytes = 1024Mb + VHDPath = "d:\VHD\CLI-01.vhdx" + SwitchName = "Arc-CLI" +} + +New-VM @vms +Set-VMMemory CLI-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB +Set-VM -Name CLI-01 -ProcessorCount 2 + +echo "Configuring adapters" +Rename-VMNetworkAdapter -VMName 'CLI-01' -NewName 'Arc-CLI' + + +### Adding and configuring CLI-03 + +echo "Adding and configuring CLI-03" +cp D:\VHD\Base\Base_Client_dif.vhdx D:\VHD\CLI-03.vhdx + +Mount-VHD d:\VHD\CLI-03.vhdx +<<<<<<< HEAD +Copy-Item d:\Scripts\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml +======= +Copy-Item d:\Unattend\Fullunattend-Win10.xml -Destination f:\Windows\Panther\Unattend.xml +>>>>>>> DNS +#mkdir e:\Tools\Scripts +#Copy-item d:\Scripts\Guests\CLI-03.ps1 E:\Tools\scripts +mkdir "f:\Program Files\BGINFO" +Copy-Item d:\Soft\BGInfo_Deploiement\BGInfox86.exe "f:\Program Files\BGINFO" +Copy-Item d:\Soft\BGInfo_Deploiement\mescouilles2.bgi "f:\Program Files\BGINFO" +Copy-Item D:\Soft\BGInfo_Deploiement\bginfox86.bat "f:\Users\AdminLocal\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" +Dismount-VHD d:\VHD\CLI-03.vhdx + +$vms = @{ + + Name = "CLI-03" + Generation = '1' + MemoryStartupBytes = 1024Mb + VHDPath = "d:\VHD\CLI-03.vhdx" + SwitchName = "Bou-LAN" +} + +New-VM @vms +Set-VMMemory CLI-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB +Set-VM -Name CLI-03 -ProcessorCount 2 + +echo "Configuring adapters" +#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Bou-LAN" -DeviceNaming on +Rename-VMNetworkAdapter -VMName 'CLI-03' -NewName 'Bou-LAN' + +### Starting VMS +echo "Starting VMs" +Start-VM -Name CLI* diff --git a/Host/Create-SRV.ps1 b/Host/Create-SRV.ps1 new file mode 100644 index 0000000..05e7a42 --- /dev/null +++ b/Host/Create-SRV.ps1 @@ -0,0 +1,67 @@ +### Adding SRV-01 + +echo "Adding and configuring SRV-01" +cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-01.vhdx + +$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 +$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 d:\Scripts\Guests\SRV-01.ps1 "${Driveletter}:\Tools\scripts\boot.ps1" + +Dismount-VHD d:\VHD\SRV-01.vhdx + +$vms = @{ + + Name = "SRV-01" + Generation = '2' + MemoryStartupBytes = 1024Mb + VHDPath = "d:\VHD\SRV-01.vhdx" + SwitchName = "Arc-SRV" +} + +New-VM @vms +Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB +Set-VM -Name SRV-01 -ProcessorCount 2 + +echo "Configuring adapters" +Rename-VMNetworkAdapter -VMName 'SRV-01' -NewName 'Arc-SRV' +Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on + +### Adding SRV-03 + +echo "Adding and configuring SRV-03" +cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-03.vhdx + +$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 +$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 d:\Scripts\Guests\SRV-03.ps1 "${Driveletter}:\Tools\scripts\boot.ps1" + +Dismount-VHD d:\VHD\SRV-03.vhdx + +$vms = @{ + + Name = "SRV-03" + Generation = '2' + MemoryStartupBytes = 1024Mb + VHDPath = "d:\VHD\SRV-03.vhdx" + SwitchName = "Bou-LAN" +} + +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 'Bou-LAN' +Set-VMNetworkAdapter -VMName 'SRV-03' -Name "Bou-Lan" -DeviceNaming on + + +Start-VM -Name SRV* diff --git a/Host/Serveurs.ps1 b/Host/Create-Serveurs.ps1 similarity index 100% rename from Host/Serveurs.ps1 rename to Host/Create-Serveurs.ps1 diff --git a/Host/SRV-Kill b/Host/SRV-Kill new file mode 100644 index 0000000..06f5a53 --- /dev/null +++ b/Host/SRV-Kill @@ -0,0 +1,3 @@ +Stop-VM SRV* -turnoff + +del d:\VHD\SRV* diff --git a/Host/Kill-Serv.ps1 b/Host/Serv-Kill.ps1 similarity index 94% rename from Host/Kill-Serv.ps1 rename to Host/Serv-Kill.ps1 index 30ca6ce..6e2f278 100644 --- a/Host/Kill-Serv.ps1 +++ b/Host/Serv-Kill.ps1 @@ -1,7 +1,7 @@ -Stop-VM RTR* -turnoff -Stop-VM SRV* -turnoff -Remove-VM RTR* -Force -Remove-VM SRV* -Force - -del d:\VHD\RTR* -del d:\VHD\SRV* +Stop-VM RTR* -turnoff +Stop-VM SRV* -turnoff +Remove-VM RTR* -Force +Remove-VM SRV* -Force + +del d:\VHD\RTR* +del d:\VHD\SRV*