Created
February 24, 2019 09:33
-
-
Save adilio/43a1d7d4d920d1fea15ccf444af85cbd to your computer and use it in GitHub Desktop.
VM Customization Bootstrap script, to prepare for Ansible management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if "%1%" == "precustomization" ( | |
echo No pre-customization tasks to run | |
) else if "%1%" == "postcustomization" ( | |
echo Running post-customization tasks | |
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff" /f | |
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f | |
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f | |
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f | |
netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes | |
( | |
echo powershell.exe -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri https://script-url/Set-Preliminaries.ps1 -OutFile C:\Users\Public\Desktop\Set-Preliminaries.ps1" | |
echo powershell.exe -ExecutionPolicy Bypass -Command C:\Users\Public\Desktop\Set-Preliminaries.ps1 | |
) > C:\Users\Administrator\Desktop\Step1_RunAsAdmin.bat | |
( | |
echo powershell.exe -ExecutionPolicy Bypass -Command "Enable-PSRemoting -Force" | |
echo reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /f /v WinRMHTTPS /t REG_SZ /d "winrm quickconfig -quiet -transport:https" | |
echo powershell.exe -ExecutionPolicy Bypass -Command "Write-Host "`nPLEASE RESTART MACHINE!`n" -ForegroundColor Red" | |
echo powershell.exe -ExecutionPolicy Bypass -Command "Restart-Computer -Confirm" | |
) > C:\Users\Public\Desktop\Step2_RunAsAdmin_AfterDomainJoin.bat | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment