Ultra commenting + echoing

Now only need testing...
This commit is contained in:
Winston Smith 2021-04-23 12:54:01 +02:00
parent bb2e9586fe
commit 7db3533a5d
9 changed files with 389 additions and 271 deletions

View File

@ -5,23 +5,36 @@
# RTR-01 Only # RTR-01 Only
# Script done # Script done
# Change the poor machine name
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman" echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
### Change the poor machine name
echo "Changing Computer's name"
Rename-computer RTR-01 Rename-computer RTR-01
# End of renaming
### Rename Adapters by parsing the VM device name
echo "Renaming adapters"
$adapts = Get-NetAdapter $adapts = Get-NetAdapter
foreach ($adapt in $adapts) { foreach ($adapt in $adapts) {
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue $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
### Pausing to let things settle
echo "Sleeping 10s" echo "Sleeping 10s"
Sleep 10 Sleep 10
#End
#Général IP configure ### Général IP configure
echo "IP configuration"
$MaskBits = 24 # This means subnet mask = 255.255.255.0 $MaskBits = 24 # This means subnet mask = 255.255.255.0
$IPType = "IPv4" $IPType = "IPv4"
@ -34,7 +47,7 @@ $adapter | New-NetIPAddress `
-IPAddress $IP ` -IPAddress $IP `
-PrefixLength $MaskBits -PrefixLength $MaskBits
#Arc-CLI #Arc-CLI conf
$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-CLI"} $adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-CLI"}
$IP = "192.168.12.254" $IP = "192.168.12.254"
@ -43,7 +56,7 @@ $adapter | New-NetIPAddress `
-IPAddress $IP ` -IPAddress $IP `
-PrefixLength $MaskBits ` -PrefixLength $MaskBits `
#WAN ### WAN conf
$adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"} $adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"}
$IP = "192.168.255.8" $IP = "192.168.255.8"
@ -53,26 +66,32 @@ $adapter | New-NetIPAddress `
-PrefixLength $MaskBits ` -PrefixLength $MaskBits `
-DefaultGateway "192.168.255.254" -DefaultGateway "192.168.255.254"
#DNS Conf for all InterfaceAlias
### 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 ('9.9.9.9') } foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
# End of scriptlet
# Install Routing and necessary linked roles ### Install Routing and necessary linked roles ###
echo "Installing Remote-Access, RSAT, Routing"
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
#Install VPN # End of scritlet
### Install VPN (necessary?) ###
echo "Installing VPN"
echo "Install-remoteAccess -VpnType Vpn" echo "Install-remoteAccess -VpnType Vpn"
Install-remoteAccess -VpnType Vpn Install-remoteAccess -VpnType Vpn
Set-NetConnectionProfile -NetworkCategory Private
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow'
}
Set-NetFirewallRule @Params # End of scritlet
# Activate NAT and DHCP Relay ### Activate NAT and DHCP Relay ###
echo "Activate NAT and DHCP Relay"
echo "Activating NAT and DHCP Relay"
netsh routing ip relay install netsh routing ip relay install
netsh routing ip add interface name="Arc-SRV" state=enable netsh routing ip add interface name="Arc-SRV" state=enable
@ -87,16 +106,27 @@ netsh routing ip relay add interface "Arc-SRV"
netsh rout ip rel set int WAN min=0 netsh rout ip rel set int WAN min=0
netsh routing ip relay add dhcpserver 192.168.8.1 netsh routing ip relay add dhcpserver 192.168.8.1
### Activating remote-access role
set-service RemoteAccess -StartupType Automatic set-service RemoteAccess -StartupType Automatic
Start-Service RemoteAccess Start-Service RemoteAccess
#END
netsh -f ./Arc-CLI.conf ### Activating DHCP Relay (Useless?)
netsh -f ./Arc-SRV.conf
netsh -f ./WAN.conf
#netsh -f ./Arc-CLI.conf
#netsh -f ./Arc-SRV.conf
#netsh -f ./WAN.conf
# End of scriptlet
### Set connection as private ###
echo "Set connection as private"
Set-NetConnectionProfile -networkcategory private Set-NetConnectionProfile -networkcategory private
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes ### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes ###
echo "Allowing ICMPv4 probes"
$Params = @{ $Params = @{
"Name" = 'vm-monitoring-icmpv4' "Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow' "Action" = 'Allow'
@ -104,9 +134,15 @@ $Params = @{
Set-NetFirewallRule @Params Set-NetFirewallRule @Params
# Add routes # End of scritlet
### Add routes
echo "Adding route"
route add -p 192.168.128.8/24 192.168.255.128 route add -p 192.168.128.8/24 192.168.255.128
route add -p 0.0.0.0/0 192.168.255.254 route add -p 0.0.0.0/0 192.168.255.254
# End of scritlet
Read-Host "Finished???" Read-Host "Finished???"

View File

@ -2,26 +2,33 @@
# GPLv3 # GPLv3
# Script to install and configure a Fuckdows Server 2016 as a router # Script to install and configure a Fuckdows Server 2016 as a router
# RTR-01 Only # RTR-02 Only
# Script done
# Change the poor machine name
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman" echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
Rename-computer RTR-02 ### Change VM name
echo "Changing computer Name"
Rename-computer RTR-02
#End
### Rename Adapters by parsing the VM device name
$adapts = Get-NetAdapter $adapts = Get-NetAdapter
foreach ($adapt in $adapts) { foreach ($adapt in $adapts) {
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue $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
### Pausing to let things settle
echo "Sleeping 30s" echo "Sleeping 30s"
Sleep 10 Sleep 10
#End
#Général IP configure ### Général IP configure
echo "IP configuration"
$MaskBits = 24 # This means subnet mask = 255.255.255.0 $MaskBits = 24 # This means subnet mask = 255.255.255.0
$IPType = "IPv4" $IPType = "IPv4"
@ -43,25 +50,47 @@ $adapter | New-NetIPAddress `
-IPAddress $IP ` -IPAddress $IP `
-PrefixLength $MaskBits ` -PrefixLength $MaskBits `
#DNS Conf for all InterfaceAlias # END
### DNS Conf for all InterfaceAlias
echo "Configuring Dns"
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') } foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
#End
### Install Routing and necessary linked roles + autostart
# Install Routing and necessary linked roles echo "Installing Remote-Access, RSAT, Routing + Auto-start"
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
set-service RemoteAccess -StartupType Automatic
Start-Service RemoteAccess
#Install VPN #END
echo "Install-remoteAccess -VpnType Vpn"
### Install VPN (?)
echo "installing VPN role"
Install-remoteAccess -VpnType Vpn Install-remoteAccess -VpnType Vpn
#End
### Set connection as Private
echo "Set connection as private"
Set-NetConnectionProfile -NetworkCategory Private Set-NetConnectionProfile -NetworkCategory Private
#END
### Activing ICMPv4 probes
echo "Activating ICMPv4 probes"
$Params = @{ $Params = @{
"Name" = 'vm-monitoring-icmpv4' "Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow' "Action" = 'Allow'
} }
Set-NetFirewallRule @Params Set-NetFirewallRule @Params
#END
### Activate NAT and DHCP Relay
# Activate NAT and DHCP Relay
echo "Activate NAT and DHCP Relay" echo "Activate NAT and DHCP Relay"
netsh routing ip relay install netsh routing ip relay install
@ -75,24 +104,12 @@ netsh routing ip relay add interface "WAN"
netsh rout ip rel set int WAN min=0 netsh rout ip rel set int WAN min=0
netsh routing ip relay add dhcpserver 192.168.8.1 netsh routing ip relay add dhcpserver 192.168.8.1
set-service RemoteAccess -StartupType Automatic #netsh -f ./WAN.conf
Start-Service RemoteAccess #netsh -f ./Bou-LAN.conf
netsh -f ./WAN.conf ### Add routes
netsh -f ./Bou-LAN.conf
Set-NetConnectionProfile -networkcategory private
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow'
}
Set-NetFirewallRule @Params
# Add routes
echo "Adding routes"
route add -p 192.168.8.0/24 192.168.255.8 route add -p 192.168.8.0/24 192.168.255.8
route add -p 192.168.12.0/24 192.168.255.8 route add -p 192.168.12.0/24 192.168.255.8
route add -p 0.0.0.0/0 192.168.255.254 route add -p 0.0.0.0/0 192.168.255.254

View File

@ -2,26 +2,35 @@
# GPLv3 # GPLv3
# Script to install and configure a Fuckdows Server 2016 as a router # Script to install and configure a Fuckdows Server 2016 as a router
# RTR-01 Only # RTR-03 Only
# Script done # Script done
# Change the poor machine name
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman" echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
Rename-computer RTR-03 ### Change the poor machine name
echo "Renaming Computer"
Rename-computer RTR-03
#END
### Rename Adapters by parsing the VM device name
echo "Renaming Computer"
$adapts = Get-NetAdapter $adapts = Get-NetAdapter
foreach ($adapt in $adapts) { foreach ($adapt in $adapts) {
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue $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
### Pausing to let things settle
echo "Sleeping 30s" echo "Sleeping 30s"
Sleep 10 Sleep 10
#Général IP configure ### Général IP configure
echo "IP Configuration"
$MaskBits = 24 # This means subnet mask = 255.255.255.0 $MaskBits = 24 # This means subnet mask = 255.255.255.0
$IPType = "IPv4" $IPType = "IPv4"
@ -40,41 +49,54 @@ $adapter | New-NetIPAddress `
$IP = "192.168.255.254" $IP = "192.168.255.254"
$adapter | Set-NetIPInterface -Dhcp Enabled $adapter | Set-NetIPInterface -Dhcp Enabled
#DNS Conf for all InterfaceAlias ### 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 ('9.9.9.9') } foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
#End
### Install Routing and necessary linked roles
# Install Routing and necessary linked roles echo "Installing Routing and necessary linked roles"
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
#Install VPN ### Install VPN (?)
echo "Install-remoteAccess -VpnType Vpn"
echo "Install Vpn"
Install-remoteAccess -VpnType Vpn Install-remoteAccess -VpnType Vpn
Set-NetConnectionProfile -NetworkCategory Private #End
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes ###
echo "Allowing ICMPv4 probes"
$Params = @{ $Params = @{
"Name" = 'vm-monitoring-icmpv4' "Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow' "Action" = 'Allow'
} }
Set-NetFirewallRule @Params Set-NetFirewallRule @Params
#END
### Activating remote-access role
echo "Activating remote-access role"
set-service RemoteAccess -StartupType Automatic set-service RemoteAccess -StartupType Automatic
Start-Service RemoteAccess Start-Service RemoteAccess
#End
netsh -f ./WAN.conf #netsh -f ./WAN.conf
### Set connection as Private
echo "Setting connection as private"
Set-NetConnectionProfile -networkcategory private Set-NetConnectionProfile -networkcategory private
#End
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow'
}
Set-NetFirewallRule @Params
# Add routes # Add routes
echo "Adding routes"
route add -p 192.168.8.0/24 192.168.255.8 route add -p 192.168.8.0/24 192.168.255.8
route add -p 192.168.12.0/24 192.168.255.8 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 192.168.128.0/24 192.168.255.128

View File

@ -5,20 +5,29 @@
# TODO : exclusion/attribution fields # TODO : exclusion/attribution fields
# Rename interfaces # Rename interfaces
# #
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman" echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
#Rename this piece of garbage ### Rename this piece of garbage
echo "Changing Computer's name"
Rename-computer "SRV-1" Rename-computer "SRV-1"
# End
# Rename interfaces ### Rename interfaces by parsing VM device name
echo "Renaming adapters"
$HVName = (Get-NetAdapterAdvancedProperty -name "Ethernet" -DisplayName "Hyper-v Network Adapter Name").DisplayValue $HVName = (Get-NetAdapterAdvancedProperty -name "Ethernet" -DisplayName "Hyper-v Network Adapter Name").DisplayValue
Rename-Netadapter -name Ethernet -NewName $HVName Rename-Netadapter -name Ethernet -NewName $HVName
#End
# Pausing to let things settle
echo "Sleeping 30s" echo "Sleeping 30s"
Sleep 10 Sleep 10
# Set IP for pre-defined MAC addresses ### Général IP configure
# echo "IP configuration"
#Arc-SRV #Arc-SRV
@ -34,27 +43,38 @@ $adapter | New-NetIPAddress `
-PrefixLength $MaskBits ` -PrefixLength $MaskBits `
-DefaultGateway 192.168.8.255 -DefaultGateway 192.168.8.255
# Set DNS ### 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 ('9.9.9.9') } foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
# Install the DHCP role (Management tools if you love Metrosexual UI) ### Install the DHCP role (Management tools if you love Metrosexual UI)
echo "Installing DHCP role"
Install-WindowsFeature DHCP -IncludeManagementTools Install-WindowsFeature DHCP -IncludeManagementTools
# Show all the interface via iproute2 - LOL no via a shitty lookalike #END
netsh inter ipv4 show inter
### Setting connection as Private
echo "Setting connection as Private"
Set-NetConnectionProfile -NetworkCategory Private Set-NetConnectionProfile -NetworkCategory Private
# Behold the LoserShell "cmdlet" to attribute static IP
#New-NetIPAddress -IPAddress 192.168.8.1 -InterfaceAlias "Arc-SRV" ` #-DefaultGateway 192.168. -AddressFamily IPv4 -PrefixLength 24
#Set-DnsClientServerAddress -InterfaceAlias "Arc-SRV" -ServerAddresses 9.9.9.9
# Create DHCP "security" groups ### Create DHCP "security" groups
echo "Creating DHCP security groups"
netsh dhcp add securitygroups netsh dhcp add securitygroups
# Restart the DHCP server #END
### Restart the DHCP server
echo "Restarting DHCP server"
Restart-Service dhcpserver Restart-Service dhcpserver
# END
###################Template####################### ###################Template#######################
#Add-DhcpServerv4Scope -name "Corpnet" -StartRange 10.0.0.1 -EndRange 10.0.0.254 -SubnetMask 255.255.255.0 -State Active #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 #Add-DhcpServerv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15
@ -62,8 +82,9 @@ Restart-Service dhcpserver
#Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2 #Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2
################################################## ##################################################
# Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan ### Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan
# Change on options after because this sucker seems to dislike if it's done now
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-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.1 -EndRange 192.168.8.63
@ -76,30 +97,36 @@ Add-DhcpServerv4ExclusionRange -ScopeID 192.168.12.0 -StartRange 192.168.12.240
Add-DhcpServerv4Scope -name "Bou-LAN" -StartRange 192.168.128.1 -EndRange 192.168.128.254 -SubnetMask 255.255.255.0 -State Active 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.1 -EndRange 192.168.128.63
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.128.0 -StartRange 192.168.128.240 -EndRange 192.168.128.254 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 ### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
echo "Allowing ICMPv4 probes"
$Params = @{ $Params = @{
"Name" = 'vm-monitoring-icmpv4' "Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow' "Action" = 'Allow'
} }
Set-NetFirewallRule @Params Set-NetFirewallRule @Params
# END
# Add routes for RTR-01 ### 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.12.0/24 192.168.8.254
route add -p 192.168.255.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 192.168.128.0/24 192.168.8.254
route add -p 0.0.0.0/0 192.168.8.254 route add -p 0.0.0.0/0 192.168.8.254
# END
# Change DHCP server options ### Change DHCP server options
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -OptionID 3 -Value 192.168.128.254 echo "Adding DHCP server options"
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -Router 192.168.128.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -DnsServer 9.9.9.9 Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -DnsServer 9.9.9.9
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -OptionID 3 -Value 192.168.12.254 Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -Router 192.168.12.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -DnsServer 9.9.9.9 Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -DnsServer 9.9.9.9
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -OptionID 3 -Value 192.168.8.254 Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -Router 192.168.8.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9 Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9
Read-Host "Finished" Read-Host "Finished?"

View File

@ -1,16 +1,19 @@
## Tool to automate VM creation ## Tool to automate VM creation
echo "Shamefully made by Alexandre Simao. Such a waste of time.`
Pardon-me dear M. Stallman"
echo "CC BY-NC-SA 4.0"
# TODO: SRV-01, RTR-02, RTR-03
# Done: RTR-01 Full auto
# Region SRV-01 echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman"
echo "GPLv3"
### Considered as finished. Need improvement VM side.
### Adding SRV-01
echo "Adding and configuring SRV-01"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\SRV-01.vhdx cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\SRV-01.vhdx
Mount-VHD 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 Copy-Item d:\Unattend\SRV-01.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir c:\Scripts
Copy-items d:\Scripts\Guests\SRV-01.ps1
Dismount-VHD d:\VHD\SRV-01.vhdx Dismount-VHD d:\VHD\SRV-01.vhdx
$vms = @{ $vms = @{
@ -26,16 +29,21 @@ $vms = @{
New-VM @vms New-VM @vms
Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
Set-VM -Name SRV-01 -ProcessorCount 2 Set-VM -Name SRV-01 -ProcessorCount 2
echo "Configuring adapters"
Rename-VMNetworkAdapter -VMName 'SRV-01' -NewName 'Arc-SRV' Rename-VMNetworkAdapter -VMName 'SRV-01' -NewName 'Arc-SRV'
Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on
# RTR-01 ### Adding and configuring RTR-01
echo "Adding and configuring RTR-01"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-01.vhdx cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-01.vhdx
Mount-VHD 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 Copy-Item d:\Unattend\RTR-01.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir c:\Scripts
Copy-items d:\Scripts\Guests\RTR-01.ps1
Dismount-VHD d:\VHD\RTR-01.vhdx Dismount-VHD d:\VHD\RTR-01.vhdx
$vms = @{ $vms = @{
@ -51,6 +59,7 @@ New-VM @vms
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
Set-VM -Name RTR-01 -ProcessorCount 2 Set-VM -Name RTR-01 -ProcessorCount 2
echo "Configuring adapters"
#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on #Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on
Rename-VMNetworkAdapter -VMName 'RTR-01' -NewName 'Arc-SRV' Rename-VMNetworkAdapter -VMName 'RTR-01' -NewName 'Arc-SRV'
Set-VMNetworkAdapter -VMName 'RTR-01' -Name "Arc-SRV" -DeviceNaming on Set-VMNetworkAdapter -VMName 'RTR-01' -Name "Arc-SRV" -DeviceNaming on
@ -60,10 +69,13 @@ Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "WAN" -Name "WAN" -DeviceNamin
# RTR-02 # RTR-02
echo "Adding and configuring RTR-02"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-02.vhdx cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-02.vhdx
Mount-VHD 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 Copy-Item d:\Unattend\RTR-02.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir c:\Scripts
Copy-items d:\Scripts\Guests\RTR-02.ps1
Dismount-VHD d:\VHD\RTR-02.vhdx Dismount-VHD d:\VHD\RTR-02.vhdx
$vms = @{ $vms = @{
@ -80,6 +92,7 @@ New-VM @vms
Set-VMMemory RTR-02 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory RTR-02 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
Set-VM -Name RTR-02 -ProcessorCount 2 Set-VM -Name RTR-02 -ProcessorCount 2
echo "Configuring adapters"
Rename-VMNetworkAdapter -VMName 'RTR-02' -NewName 'Bou-Lan' Rename-VMNetworkAdapter -VMName 'RTR-02' -NewName 'Bou-Lan'
Set-VMNetworkAdapter -VMName 'RTR-02' -Name "Bou-LAN" -DeviceNaming on Set-VMNetworkAdapter -VMName 'RTR-02' -Name "Bou-LAN" -DeviceNaming on
Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNaming on Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
@ -88,11 +101,13 @@ Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNamin
# RTR-03 # RTR-03
echo "Adding and configuring RTR-03"
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-03.vhdx cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-03.vhdx
Mount-VHD 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 Copy-Item d:\Unattend\RTR-03.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir c:\Scripts
Copy-items d:\Scripts\Guests\RTR-03.ps1
Dismount-VHD d:\VHD\RTR-03.vhdx Dismount-VHD d:\VHD\RTR-03.vhdx
$vms = @{ $vms = @{
@ -109,11 +124,12 @@ New-VM @vms
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
Set-VM -Name RTR-03 -ProcessorCount 2 Set-VM -Name RTR-03 -ProcessorCount 2
echo "Configuring adapters"
Rename-VMNetworkAdapter -VMName 'RTR-03' -NewName 'WAN' Rename-VMNetworkAdapter -VMName 'RTR-03' -NewName 'WAN'
Set-VMNetworkAdapter -VMName 'RTR-03' -Name "WAN" -DeviceNaming on Set-VMNetworkAdapter -VMName 'RTR-03' -Name "WAN" -DeviceNaming on
Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "Aston" -Name "Aston" -DeviceNaming on Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "Aston" -Name "Aston" -DeviceNaming on
### Starting VMS
echo "Starting VMs"
Start-VM -Name RTR* Start-VM -Name RTR*
Start-VM -Name SRV* Start-VM -Name SRV*

View File

@ -1,7 +1,7 @@
Stop-VM RTR* -turnoff Stop-VM RTR* -turnoff
Stop-VM SRV* -turnoff Stop-VM SRV* -turnoff
Remove-VM RTR* Remove-VM RTR* -Force
Remove-VM SRV* Remove-VM SRV* -Force
del d:\VHD\RTR* del d:\VHD\RTR*
del d:\VHD\SRV* del d:\VHD\SRV*