From 44cf01520ac280eb1ec97d123a459273485e8235 Mon Sep 17 00:00:00 2001 From: Winston Smith Date: Fri, 23 Apr 2021 17:37:49 +0200 Subject: [PATCH] Last version before end of week. Need to refactor routing conf (via netsh) and reboots. --- Guests/RTR-01.ps1 | 23 ++++------------------- Guests/RTR-02.ps1 | 15 +++------------ Guests/RTR-03.ps1 | 14 ++++---------- Guests/SRV-01.ps1 | 20 +++++++------------- Host/Infra-Standard.ps1 | 17 ++++++++--------- 5 files changed, 26 insertions(+), 63 deletions(-) diff --git a/Guests/RTR-01.ps1 b/Guests/RTR-01.ps1 index b72e296..16fe603 100644 --- a/Guests/RTR-01.ps1 +++ b/Guests/RTR-01.ps1 @@ -40,31 +40,16 @@ $IPType = "IPv4" #Arc-SRV IP conf -$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"} -$IP = "192.168.8.254" -$adapter | New-NetIPAddress ` - -AddressFamily $IPType ` - -IPAddress $IP ` - -PrefixLength $MaskBits +netsh interface ip set address name="Arc-SRV" static 192.168.8.254 255.255.255.0 #Arc-CLI conf - $adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-CLI"} - $IP = "192.168.12.254" - $adapter | New-NetIPAddress ` - -AddressFamily $IPType ` - -IPAddress $IP ` - -PrefixLength $MaskBits ` + netsh interface ip set address name="Arc-CLI" static 192.168.12.8 255.255.255.0 ### WAN conf -$adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"} -$IP = "192.168.255.8" -$adapter | New-NetIPAddress ` - -AddressFamily $IPType ` - -IPAddress $IP ` - -PrefixLength $MaskBits ` - -DefaultGateway "192.168.255.254" +netsh interface ip set address name="WAN" static 192.168.255.8 255.255.255.0` +192.168.255.254 ### DNS Conf for all InterfaceAlias ### diff --git a/Guests/RTR-02.ps1 b/Guests/RTR-02.ps1 index 6dd04a9..81616b5 100644 --- a/Guests/RTR-02.ps1 +++ b/Guests/RTR-02.ps1 @@ -34,21 +34,12 @@ $IPType = "IPv4" #Bou-LAN IP conf -$adapter = Get-NetAdapter | ? {$_.Name -eq "Bou-LAN"} -$IP = "192.168.128.254" -$adapter | New-NetIPAddress ` - -AddressFamily $IPType ` - -IPAddress $IP ` - -PrefixLength $MaskBits +netsh interface ip set address name="Bou-LAN" static 192.168.128.254 255.255.255.0 #WAN - $adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"} - $IP = "192.168.255.254" - $adapter | New-NetIPAddress ` - -AddressFamily $IPType ` - -IPAddress $IP ` - -PrefixLength $MaskBits ` + netsh interface ip set address name="WAN" static 192.168.255.128 255.255.255.0` + 192.168.255.254 # END diff --git a/Guests/RTR-03.ps1 b/Guests/RTR-03.ps1 index bf79c27..e710f5e 100644 --- a/Guests/RTR-03.ps1 +++ b/Guests/RTR-03.ps1 @@ -19,7 +19,7 @@ echo "Renaming Computer" $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" +Rename-Netadapter -name $adapt.name -NewName $HVName } #End @@ -36,18 +36,11 @@ $IPType = "IPv4" #WAN IP conf -$adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"} -$IP = "192.168.255.254" -$adapter | New-NetIPAddress ` - -AddressFamily $IPType ` - -IPAddress $IP ` - -PrefixLength $MaskBits +netsh interface ip set address name="WAN" static 192.168.255.254 255.255.255.0 #Aston - $adapter = Get-NetAdapter | ? {$_.Name -eq "Aston"} - $IP = "192.168.255.254" - $adapter | Set-NetIPInterface -Dhcp Enabled + netsh interface ip set address name="Aston" DHCP ### DNS Conf for all InterfaceAlias @@ -102,4 +95,5 @@ route add -p 192.168.12.0/24 192.168.255.8 route add -p 192.168.128.0/24 192.168.255.128 route add -p 0.0.0.0/0 192.168.255.254 +ipconfig /renew Read-Host "Finished???" diff --git a/Guests/SRV-01.ps1 b/Guests/SRV-01.ps1 index 6a3f285..f12bb4a 100644 --- a/Guests/SRV-01.ps1 +++ b/Guests/SRV-01.ps1 @@ -17,8 +17,11 @@ Rename-computer "SRV-1" ### Rename interfaces by parsing VM device name echo "Renaming adapters" -$HVName = (Get-NetAdapterAdvancedProperty -name "Ethernet" -DisplayName "Hyper-v Network Adapter Name").DisplayValue -Rename-Netadapter -name Ethernet -NewName $HVName +$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 @@ -31,17 +34,8 @@ Sleep 10 #Arc-SRV -$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-SRV"} - -$IP = "192.168.8.1" -$MaskBits = 24 # This means subnet mask = 255.255.255.0 -$IPType = "IPv4" - -$adapter | New-NetIPAddress ` - -AddressFamily $IPType ` - -IPAddress $IP ` - -PrefixLength $MaskBits ` - -DefaultGateway 192.168.8.255 +netsh interface ip set address name="Arc-SRV" static 192.168.8.1 255.255.255.0` +192.168.8.255 ### DNS Conf for all InterfaceAlias ### diff --git a/Host/Infra-Standard.ps1 b/Host/Infra-Standard.ps1 index e4e0473..18595cd 100644 --- a/Host/Infra-Standard.ps1 +++ b/Host/Infra-Standard.ps1 @@ -12,8 +12,8 @@ cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\SRV-01.vhdx Mount-VHD d:\VHD\SRV-01.vhdx Copy-Item d:\Unattend\SRV-01.xml -Destination e:\Windows\Panther\Unattend.xml -mkdir c:\Scripts -Copy-items d:\Scripts\Guests\SRV-01.ps1 +mkdir e:\Tools\Scripts +Copy-item d:\Scripts\Guests\SRV-01.ps1 E:\Tools\scripts Dismount-VHD d:\VHD\SRV-01.vhdx $vms = @{ @@ -23,7 +23,6 @@ $vms = @{ MemoryStartupBytes = 1024Mb VHDPath = "d:\VHD\SRV-01.vhdx" SwitchName = "Arc-SRV" - } New-VM @vms @@ -42,8 +41,8 @@ cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-01.vhdx Mount-VHD d:\VHD\RTR-01.vhdx Copy-Item d:\Unattend\RTR-01.xml -Destination e:\Windows\Panther\Unattend.xml -mkdir c:\Scripts -Copy-items d:\Scripts\Guests\RTR-01.ps1 +mkdir e:\Tools\Scripts +Copy-item d:\Scripts\Guests\RTR-01.ps1 E:\Tools\scripts Dismount-VHD d:\VHD\RTR-01.vhdx $vms = @{ @@ -74,8 +73,8 @@ cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-02.vhdx Mount-VHD d:\VHD\RTR-02.vhdx Copy-Item d:\Unattend\RTR-02.xml -Destination e:\Windows\Panther\Unattend.xml -mkdir c:\Scripts -Copy-items d:\Scripts\Guests\RTR-02.ps1 +mkdir e:\Tools\Scripts +Copy-item D:\scripts\Guests\RTR-02.ps1 E:\Tools\scripts Dismount-VHD d:\VHD\RTR-02.vhdx $vms = @{ @@ -106,8 +105,8 @@ cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-03.vhdx Mount-VHD d:\VHD\RTR-03.vhdx Copy-Item d:\Unattend\RTR-03.xml -Destination e:\Windows\Panther\Unattend.xml -mkdir c:\Scripts -Copy-items d:\Scripts\Guests\RTR-03.ps1 +mkdir e:\Tools\Scripts +Copy-item d:\Scripts\Guests\RTR-03.ps1 E:\Tools\scripts Dismount-VHD d:\VHD\RTR-03.vhdx $vms = @{