Feat: Add bootstrap script
This commit is contained in:
parent
b5ba42cfc7
commit
e219cd7af8
69
Guests/SRV-02.ps1
Normal file
69
Guests/SRV-02.ps1
Normal file
@ -0,0 +1,69 @@
|
||||
# Alexandre Simao
|
||||
# GPL v3
|
||||
|
||||
# SRV-02 ONLY
|
||||
# asrc.local domain
|
||||
|
||||
# TODO: Delegation
|
||||
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
### Rename this piece of garbage
|
||||
|
||||
echo "Changing Computer's name"
|
||||
Rename-computer "SRV-02"
|
||||
# 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.2 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,192.168.128.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
|
||||
|
||||
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
|
||||
echo "Allowing ICMPv4 probes"
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
# END
|
||||
|
||||
|
||||
Read-Host "Finished?"
|
||||
Restart-Computer
|
@ -3,5 +3,15 @@ Stop-VM SRV* -turnoff
|
||||
Remove-VM RTR* -Force
|
||||
Remove-VM SRV* -Force
|
||||
|
||||
#Dismount-VHD –Path d:\VHD\SRV-01.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\SRV-02.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\SRV-03.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\RTR-01.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\RTR-02.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\RTR-03.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\CLI-01.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\CLI-02.vhdx
|
||||
#Dismount-VHD –Path d:\VHD\CLI-03.vhdx
|
||||
|
||||
del d:\VHD\RTR*
|
||||
del d:\VHD\SRV*
|
||||
|
6
Host/Bootstrap-Hyper-V.ps1
Normal file
6
Host/Bootstrap-Hyper-V.ps1
Normal file
@ -0,0 +1,6 @@
|
||||
New-Item -Path "d:\" -Name "VHD" -ItemType "directory"
|
||||
New-Item -Path "d:\" -Name "VM" -ItemType "directory"
|
||||
New-Item -Path "d:\VHD" -Name "Base" -ItemType "directory"
|
||||
Move-Item d:/sources d:/VHD/
|
||||
New-VHD -ParentPath d:\VHD\source\Base_2016_14393.161220_StdGUI_G2_upd28022017.vhdx -Path d:\VHD\Base\Base_SRV_diff.vhdx -Differencing
|
||||
New-VHD -ParentPath d:\VHD\source\Master_Win10_20h2_x86_G1.vhdx -Path d:\VHD\Base\Base_CLI_diff.vhdx -Differencing
|
@ -30,6 +30,39 @@ 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
|
||||
|
||||
$Lettre = Mount-VHD -Path "d:\VHD\SRV-02.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-02.ps1 "${Driveletter}:\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"
|
||||
|
3
Memo.ps1
3
Memo.ps1
@ -84,3 +84,6 @@ Start-Sleep -Seconds 5
|
||||
#Replicate the Forwardlookup zones into two additional Public DNS servers
|
||||
Add-DnsServerSecondaryZone -ComputerName $SecondaryDNSServer1 -MasterServers [System.Net.Dns]::GetHostAddresses($PrimaryDNSServer).IPAddressToString -Name $DomainNames -ZoneFile "$DomainNames.dns"
|
||||
Add-DnsServerSecondaryZone -ComputerName $SecondaryDNSServer2 -MasterServers [System.Net.Dns]::GetHostAddresses($PrimaryDNSServer).IPAddressToString -Name $DomainNames -ZoneFile "$DomainNames.dns"
|
||||
|
||||
|
||||
Get-WindowsCapability -name "*RSAT*" -online|Add-WindowsCapability -online
|
||||
|
Loading…
Reference in New Issue
Block a user