Chore: Remove SRV-02

This commit is contained in:
Alexandre-Simao 2021-05-31 14:43:26 +02:00
parent 42db1e9fd1
commit ac7d11930d
2 changed files with 124 additions and 30 deletions

124
Guests/SRV-03.ps1 Normal file
View File

@ -0,0 +1,124 @@
# Alexandre Simao
# GPL v3
# SRV-01 ONLY
# TODO : exclusion/attribution fields
# Rename interfaces
#
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
### Rename this piece of garbage
echo "Changing Computer's name"
Rename-computer "SRV-1"
# End
### Rename interfaces by parsing VM device name
echo "Renaming adapters"
$adapts = Get-NetAdapter
foreach ($adapt in $adapts) {
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
Rename-Netadapter -name $adapt.name -NewName $HVName
}
#End
# Pausing to let things settle
echo "Sleeping 10s"
Sleep 10
### Général IP configure
# echo "IP configuration"
#Arc-SRV
netsh interface ip set address name="Arc-SRV" static 192.168.8.1 255.255.255.0 192.168.8.254
### DNS Conf for all InterfaceAlias ###
echo "DNS Conf"
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('192.168.8.1') }
### Install the DHCP role (Management tools if you love Metrosexual UI)
echo "Installing DHCP role"
Install-WindowsFeature DHCP -IncludeManagementTools
#END
### Setting connection as Private
echo "Setting connection as Private"
Set-NetConnectionProfile -NetworkCategory Private
### Create DHCP "security" groups
echo "Creating DHCP security groups"
netsh dhcp add securitygroups
#END
### Restart the DHCP server
echo "Restarting DHCP server"
Restart-Service dhcpserver
# END
###################Template#######################
#Add-DhcpServerv4Scope -name "Corpnet" -StartRange 10.0.0.1 -EndRange 10.0.0.254 -SubnetMask 255.255.255.0 -State Active
#Add-DhcpServerv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15
#Set-DhcpServerv4OptionValue -OptionID 3 -Value 10.0.0.1 -ScopeID 10.0.0.0 -ComputerName DHCP1.corp.contoso.com
#Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2
##################################################
### Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan
echo "Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan"
Add-DhcpServerv4Scope -name "Arc-SRV" -StartRange 192.168.8.1 -EndRange 192.168.8.254 -SubnetMask 255.255.255.0 -State Active
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.8.0 -StartRange 192.168.8.1 -EndRange 192.168.8.63
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.8.0 -StartRange 192.168.8.240 -EndRange 192.168.8.254
Add-DhcpServerv4Scope -name "Arc-CLI" -StartRange 192.168.12.1 -EndRange 192.168.12.254 -SubnetMask 255.255.255.0 -State Active
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.12.0 -StartRange 192.168.12.1 -EndRange 192.168.12.63
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.12.0 -StartRange 192.168.12.240 -EndRange 192.168.12.254
Add-DhcpServerv4Scope -name "Bou-LAN" -StartRange 192.168.128.1 -EndRange 192.168.128.254 -SubnetMask 255.255.255.0 -State Active
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.128.0 -StartRange 192.168.128.1 -EndRange 192.168.128.63
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.128.0 -StartRange 192.168.128.240 -EndRange 192.168.128.254
#END
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
echo "Allowing ICMPv4 probes"
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow'
}
Set-NetFirewallRule @Params
# END
### Add routes for RTR-01
echo "Add routes for RTR-01"
route add -p 192.168.12.0/24 192.168.8.254
route add -p 192.168.255.0/24 192.168.8.254
route add -p 192.168.128.0/24 192.168.8.254
route add -p 0.0.0.0/0 192.168.8.254
# END
### Change DHCP server options
echo "Adding DHCP server options"
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -Router 192.168.128.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -Router 192.168.12.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -Router 192.168.8.254
Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 192.168.8.1
Read-Host "Finished?"
Restart-Computer

View File

@ -34,36 +34,6 @@ echo "Configuring adapters"
Rename-VMNetworkAdapter -VMName 'SRV-01' -NewName 'Arc-SRV'
Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on
### Adding SRV-02
echo "Adding and configuring SRV-02"
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-02.vhdx
Mount-VHD d:\VHD\SRV-02.vhdx
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml
Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd
mkdir e:\Tools\Scripts
Copy-item d:\Scripts\Guests\SRV-02.ps1 E:\Tools\scripts\boot.ps1
Dismount-VHD d:\VHD\SRV-02.vhdx
$vms = @{
Name = "SRV-02"
Generation = '2'
MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\SRV-02.vhdx"
SwitchName = "Arc-SRV"
}
New-VM @vms
Set-VMMemory SRV-02 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
Set-VM -Name SRV-02 -ProcessorCount 2
echo "Configuring adapters"
Rename-VMNetworkAdapter -VMName 'SRV-02' -NewName 'Arc-SRV'
Set-VMNetworkAdapter -VMName 'SRV-02' -Name "Arc-SRV" -DeviceNaming on
### Adding SRV-03
echo "Adding and configuring SRV-03"