diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 new file mode 100644 index 0000000..80a929c --- /dev/null +++ b/automation/SetUp.ps1 @@ -0,0 +1,18 @@ +$SwitchName = "External VM Switch" +$ISOFile = "$HOME\Downloads\SERVER_EVAL_x64FRE_en-us-uni.iso" +$VMName = 'minikube-ws22' +$VM = @{ + Name = $VMName; + MemoryStartupBytes = 1GB; + NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx"; + NewVHDSizeBytes = 15GB; + BootDevice = "VHD"; + Path = "${env:homepath}\.minikube\machines\"; + SwitchName = $SwitchName +} +New-VM @VM +Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false +Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true +Set-VMDvdDrive -VMName $VMName -Path $ISOFile +Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 +Start-VM -Name $VMName \ No newline at end of file diff --git a/automation/auto-install.iso b/automation/auto-install.iso new file mode 100644 index 0000000..7ed2d7b Binary files /dev/null and b/automation/auto-install.iso differ diff --git a/automation/autounattend.xml b/automation/autounattend.xml new file mode 100644 index 0000000..51d9d00 --- /dev/null +++ b/automation/autounattend.xml @@ -0,0 +1,169 @@ + + + + + + en-US + + en-US + en-US + en-US + en-US + + + + + + + 250 + 1 + Primary + + + 2 + true + Primary + + + + + 1 + 1 + NTFS + + true + + + 2 + 2 + NTFS + + + + 0 + true + + + + + + + + + /IMAGE/INDEX + 3 + + + + 0 + 2 + + OnError + false + + + + true + + Never + + + + + + + + + + + en-US + en-US + en-US + en-US + en-US + + + + minikube-ws22 + Central Standard Time + true + + + + true + + + + + + + + Minikube@2024 + true</PlainText> + </Password> + <Username>Administrator</Username> + <Enabled>true</Enabled> + </AutoLogon> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "WinRMCertificate"</CommandLine> + <Description>Certificate for WinRM</Description> + <Order>1</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Enable-PSRemoting -SkipNetworkProfileCheck -Force</CommandLine> + <Description>Enable WinRM</Description> + <Order>2</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command ($cert = gci Cert:\LocalMachine\My\) -and (New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force)</CommandLine> + <Description>Add HTTPS WinRM listener with previously generated certificate</Description> + <Order>3</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-NetFirewallRule -DisplayName 'Windows Remote Management (HTTPS-In)' -Name 'Windows Remote Management (HTTPS-In)' -Profile Any -LocalPort 5986 -Protocol TCP</CommandLine> + <Description>Add firewall exception to TCP port 5986 for WinRM over HTTPS</Description> + <Order>4</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true</CommandLine> + <Description>Enable Basic authentication</Description> + <Order>5</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Stop-Service WinRM</CommandLine> + <Description>Stop the WinRM service to allow the dism process to finish before packer executes scripts</Description> + <Order>6</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Install-WindowsFeature -Name containers</CommandLine> + <Order>7</Order> + <Description>Installs Containers feature</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-SConfig -AutoLaunch $false</CommandLine> + <Order>8</Order> + <Description>Turns off Server Configuration tool (SConfig)</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + <Order>9</Order> + <Description>Restart computer to apply changes</Description> + </SynchronousCommand> + </FirstLogonCommands> + <UserAccounts> + <AdministratorPassword> + <Value>Minikube@2024</Value> + <PlainText>true</PlainText> + </AdministratorPassword> + </UserAccounts> + </component> + </settings> + <cpi:offlineImage cpi:source="wim:c:/wims/install.wim#Windows Server 2022 SERVERDATACENTER" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> +</unattend> \ No newline at end of file