├── .gitignore ├── README.md ├── Vagrantfile ├── post-boot-machine.sh ├── post-boot.sh ├── selenium.bat ├── selenium_conf ├── VISTA │ └── IE7 │ │ └── config.json ├── WIN7 │ ├── IE10 │ │ └── config.json │ ├── IE11 │ │ └── config.json │ ├── IE8 │ │ └── config.json │ └── IE9 │ │ └── config.json ├── WIN8 │ ├── IE10 │ │ └── config.json │ └── IE11 │ │ └── config.json ├── XP │ ├── IE6 │ │ └── config.json │ └── IE8 │ │ └── config.json └── selenium.bat ├── vagrant_prepare.bat └── vagrant_prepare.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vagrant 3 | *.iml 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ie-selenium 2 | =========== 3 | 4 | Sets up local IE instances for Selenium testing using Vagrant + modern.ie + VirtualBox. 5 | 6 | The Vagrant boxes are created and hosted by modern.ie. Unfortunately remote management is disabled so that Vagrant 7 | provisioning cannot be used. There is a post-boot.sh script that will update the Vagrant boxes with Java and Selenium. 8 | Selenium is set up in stand alone mode, not as nodes in a grid, although modifications could be done to these scripts to 9 | make it happen. 10 | 11 | Selenium code and configurations have been borrowed from https://github.com/conceptsandtraining/modernie_selenium. 12 | 13 | Some configurations based on https://gist.github.com/tvjames/6750255. 14 | 15 | The scripts were written on Mac OS X 10.10. They may not work on Linux or cygwin. Send pull requests if you'd like to fix 16 | them. 17 | 18 | How To 19 | ------ 20 | 21 | For each box (in this case IE10_Win7): 22 | ``` 23 | vagrant up IE10_Win7 24 | ``` 25 | 26 | Provisioning won't work so vagrant will fail, but the VM will be created. 27 | 28 | After all boxes are created: 29 | ``` 30 | ./post-boot.sh 31 | ``` 32 | 33 | If you want to install Selenium on a single box (replace IE10_Win7 with the box name): 34 | ``` 35 | ./post-boot-machine.sh $(cat .vagrant/machines/IE10_Win7/virtualbox/id) 36 | ``` 37 | 38 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | config.vm.post_up_message = "Execute ./post-boot.sh to install Selenium in each VM.\nConnect Selenium to http://localhost:44444/wd/hub" 9 | 10 | config.vm.define "IE6_WinXP" do |v| 11 | v.vm.box = "IE6_WinXP" 12 | v.vm.box_url = "http://aka.ms/vagrant-xp-ie6" 13 | end 14 | 15 | config.vm.define "IE8_WinXP" do |v| 16 | v.vm.box = "IE8_WinXP" 17 | v.vm.box_url = "http://aka.ms/vagrant-xp-ie8" 18 | end 19 | 20 | config.vm.define "IE7_Vista" do |v| 21 | v.vm.box = "IE7_Vista" 22 | v.vm.box_url = "http://aka.ms/vagrant-vista-ie7" 23 | end 24 | 25 | config.vm.define "IE8_Win7" do |v| 26 | v.vm.box = "IE8_Win7" 27 | v.vm.box_url = "http://aka.ms/vagrant-win7-ie8" 28 | end 29 | 30 | config.vm.define "IE9_Win7" do |v| 31 | v.vm.box = "IE9_Win7" 32 | v.vm.box_url = "http://aka.ms/vagrant-win7-ie9" 33 | end 34 | 35 | config.vm.define "IE10_Win7" do |v| 36 | v.vm.box = "IE10_Win7" 37 | v.vm.box_url = "http://aka.ms/vagrant-win7-ie10" 38 | end 39 | 40 | config.vm.define "IE11_Win7" do |v| 41 | v.vm.box = "IE11_Win7" 42 | v.vm.box_url = "http://aka.ms/vagrant-win7-ie11" 43 | end 44 | 45 | config.vm.define "IE10_Win8" do |v| 46 | v.vm.box = "IE10_Win8" 47 | v.vm.box_url = "http://aka.ms/vagrant-win8-ie10" 48 | end 49 | 50 | config.vm.define "IE11_Win81" do |v| 51 | v.vm.box = "IE11_Win81" 52 | v.vm.box_url = "http://aka.ms/vagrant-win81-ie11" 53 | end 54 | 55 | config.vm.communicator = "winrm" 56 | config.winrm.username = "IEUser" 57 | config.winrm.password = "Passw0rd!" 58 | config.windows.set_work_network = true 59 | 60 | # Create a forwarded port mapping which allows access to a specific port 61 | # within the machine from a port on the host machine. In the example below, 62 | # accessing "localhost:8080" will access port 80 on the guest machine. 63 | # config.vm.network "forwarded_port", guest: 80, host: 8080 64 | config.vm.network "forwarded_port", guest: 4444, host: 44444 65 | 66 | # Create a private network, which allows host-only access to the machine 67 | # using a specific IP. 68 | # config.vm.network "private_network", ip: "192.168.33.10" 69 | 70 | # Create a public network, which generally matched to bridged network. 71 | # Bridged networks make the machine appear as another physical device on 72 | # your network. 73 | # config.vm.network "public_network" 74 | 75 | # Share an additional folder to the guest VM. The first argument is 76 | # the path on the host to the actual folder. The second argument is 77 | # the path on the guest to mount the folder. And the optional third 78 | # argument is a set of non-required options. 79 | # config.vm.synced_folder "../data", "/vagrant_data" 80 | 81 | # Provider-specific configuration so you can fine-tune various 82 | # backing providers for Vagrant. These expose provider-specific options. 83 | # Example for VirtualBox: 84 | # 85 | config.vm.provider "virtualbox" do |vb| 86 | vb.gui = true 87 | # Trusting modernie team to set the correct memory settings 88 | #vb.memory = 1024 89 | vb.customize ["modifyvm", :id, "--vrde", "on"] 90 | end 91 | end 92 | -------------------------------------------------------------------------------- /post-boot-machine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Updates a new Vagrant machine based on modernie to run selenium 4 | 5 | #set -x 6 | #set -e 7 | 8 | if [ -z "$1" ]; then 9 | echo Missing VM ID 10 | exit 1 11 | fi 12 | 13 | id=$1 14 | # FIXME: IE version, not important unless configuring a Selenium Grid node 15 | vm_ie=IE10 16 | GC_OPTS="--username IEUser --password Passw0rd! --verbose" 17 | HEADLESS="--type headless" 18 | DOWNLOADS="${HOME}/Downloads" 19 | FILES="$(pwd)" 20 | 21 | # Check for downloads 22 | DEUAC="${DOWNLOADS}/deuac.iso" 23 | JREWIN="$(ls ${DOWNLOADS}/jre*windows*exe | head -n 1)" 24 | SELENIUM="$(ls ${DOWNLOADS}/selenium-server-standalone*.jar | head -n 1)" 25 | IEDRIVER="${DOWNLOADS}/IEDriverServer.exe" 26 | 27 | downloads_needed=0 28 | if [ ! -f "${DEUAC}" ]; then 29 | downloads_needed=1 30 | echo "deuac.iso missing, download into ${DOWNLOADS} from https://github.com/tka/SeleniumBox/blob/master/deuac.iso" >&2 31 | fi 32 | if [ ! -f "${JREWIN}" ]; then 33 | downloads_needed=1 34 | echo "Windows JRE missing, download into ${DOWNLOADS} from http://www.oracle.com/technetwork/java/javase/downloads/index.html" >&2 35 | fi 36 | if [ ! -f "${SELENIUM}" ]; then 37 | downloads_needed=1 38 | echo "selenium-server-standalone*.jar missing, download into ${DOWNLOADS} from http://www.seleniumhq.org/download/" >&2 39 | fi 40 | if [ ! -f "${IEDRIVER}" ]; then 41 | downloads_needed=1 42 | echo "IEDriverServer.exe missing, download into ${DOWNLOADS} from http://www.seleniumhq.org/download/" >&2 43 | fi 44 | [ "${downloads_needed}" -eq 0 ] || exit 1 45 | 46 | waitforgc() { 47 | sleep 5s 48 | until VBoxManage guestcontrol $id stat 'C:/' ${GC_OPTS} >/dev/null; do 49 | sleep 5s 50 | done 51 | } 52 | 53 | startvm() { 54 | if VBoxManage list runningvms | grep -q $id; then 55 | true 56 | else 57 | VBoxManage startvm $id ${HEADLESS} || exit 1 58 | fi 59 | waitforgc 60 | } 61 | 62 | waitforstop() { 63 | while VBoxManage list runningvms | grep -q $id; do 64 | sleep 5s 65 | done 66 | } 67 | 68 | stopvm() { 69 | if VBoxManage list runningvms | grep -q $id; then 70 | VBoxManage controlvm $id acpipowerbutton || VBoxManage controlvm $id poweroff 71 | sleep 3s 72 | fi 73 | waitforstop 74 | } 75 | 76 | disable_uac() { 77 | stopvm 78 | VBoxManage storageattach $id --storagectl "IDE" --port 1 --device 0 --type dvddrive --medium "${DEUAC}" || exit 1 79 | VBoxManage startvm $id ${HEADLESS} || exit 1 80 | # The deuac.iso starts, mods the VM, and then stops the VM 81 | waitforstop 82 | VBoxManage storageattach $id --storagectl "IDE" --port 1 --device 0 --type dvddrive --medium none || exit 1 83 | } 84 | 85 | prepare() { 86 | VBoxManage guestcontrol $id mkdir "C:/Temp" --parents ${GC_OPTS} || exit 1 87 | } 88 | 89 | configure() { 90 | # Powershell hangs, even when run from a .bat file, not sure why 91 | #VBoxManage guestcontrol $id copyto "${FILES}/vagrant_prepare.bat" "C:/Temp/vagrant_prepare.bat" ${GC_OPTS} || exit 1 92 | #VBoxManage guestcontrol $id copyto "${FILES}/vagrant_prepare.ps1" "C:/Temp/vagrant_prepare.ps1" ${GC_OPTS} || exit 1 93 | #VBoxManage guestcontrol $id execute --image "C:/Temp/vagrant_prepare.bat" ${GC_OPTS} --wait-exit || exit 1 94 | VBoxManage guestcontrol $id execute --image 'C:/windows/system32/netsh.exe' ${GC_OPTS} -- advfirewall set allprofiles state off 95 | waitforgc 96 | } 97 | 98 | install_java() { 99 | VBoxManage guestcontrol $id copyto "${JREWIN}" "C:/Temp/jre.exe" ${GC_OPTS} || exit 1 100 | VBoxManage guestcontrol $id execute --image "C:/Temp/jre.exe" ${GC_OPTS} --wait-exit -- /s || exit 1 101 | } 102 | 103 | install_selenium() { 104 | VBoxManage guestcontrol $id mkdir "C:/selenium" --parents ${GC_OPTS} || exit 1 105 | VBoxManage guestcontrol $id copyto "${SELENIUM}" 'C:/selenium/selenium-server-standalone.jar' ${GC_OPTS} || exit 1 106 | VBoxManage guestcontrol $id copyto "${FILES}/selenium.bat" 'C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Startup/selenium.bat' ${GC_OPTS} || exit 1 107 | VBoxManage guestcontrol $id copyto "${FILES}/selenium_conf/WIN7/${vm_ie}/config.json" 'C:/selenium/config.json' ${GC_OPTS} || exit 1 108 | VBoxManage guestcontrol $id copyto "${IEDRIVER}" 'C:/Windows/system32/IEDriverServer.exe' ${GC_OPTS} || exit 1 109 | } 110 | 111 | # snapshots cause problems with vagrant (1.6 ATM) when destroying 112 | #VBoxManage snapshot $id take "modernie base" 113 | disable_uac 114 | startvm 115 | prepare 116 | configure 117 | install_java 118 | install_selenium 119 | stopvm 120 | #VBoxManage snapshot $id take "selenium base" 121 | -------------------------------------------------------------------------------- /post-boot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #set -x 4 | #set -e 5 | 6 | # Updates all Vagrant machines based on modernie to run selenium 7 | 8 | for ID in .vagrant/machines/*/virtualbox/id; do 9 | $(dirname $0)/post-boot-machine.sh $(cat $ID) || exit 1 10 | done 11 | -------------------------------------------------------------------------------- /selenium.bat: -------------------------------------------------------------------------------- 1 | rem java.exe -jar c:\selenium\selenium-server-standalone.jar -role node -nodeConfig c:\selenium\config.json 2 | java.exe -jar c:\selenium\selenium-server-standalone.jar 3 | -------------------------------------------------------------------------------- /selenium_conf/VISTA/IE7/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "VISTA", 12 | "browserName": "internet explorer", 13 | "version": 7, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "VISTA", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "VISTA", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/WIN7/IE10/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "WINDOWS", 12 | "browserName": "internet explorer", 13 | "version": 10, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "WINDOWS", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "WINDOWS", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/WIN7/IE11/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "WINDOWS", 12 | "browserName": "internet explorer", 13 | "version": 11, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "WINDOWS", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "WINDOWS", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/WIN7/IE8/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "WINDOWS", 12 | "browserName": "internet explorer", 13 | "version": 8, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "WINDOWS", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "WINDOWS", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/WIN7/IE9/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "WINDOWS", 12 | "browserName": "internet explorer", 13 | "version": 9, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "WINDOWS", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "WINDOWS", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/WIN8/IE10/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "WIN8", 12 | "browserName": "internet explorer", 13 | "version": 10, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "WIN8", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "WIN8", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/WIN8/IE11/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "WIN8", 12 | "browserName": "internet explorer", 13 | "version": 11, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "WIN8", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "WIN8", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/XP/IE6/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "XP", 12 | "browserName": "internet explorer", 13 | "version": 6, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "XP", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "XP", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/XP/IE8/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "port": 5555, 4 | "register": true, 5 | "registerCycle": 5000, 6 | "hubPort": 4444, 7 | "hubHost": "192.168.1.23" 8 | }, 9 | "capabilities": [ 10 | { 11 | "platform": "XP", 12 | "browserName": "internet explorer", 13 | "version": 8, 14 | "maxInstances": 1, 15 | "seleniumProtocol": "WebDriver" 16 | }, 17 | { 18 | "platform": "XP", 19 | "browserName": "firefox", 20 | "maxInstances": 1, 21 | "seleniumProtocol": "WebDriver" 22 | }, 23 | { 24 | "platform": "XP", 25 | "browserName": "chrome", 26 | "maxInstances": 1, 27 | "seleniumProtocol": "WebDriver" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /selenium_conf/selenium.bat: -------------------------------------------------------------------------------- 1 | "C:\Program Files\Java\jre7\bin\java.exe" -jar c:\selenium\selenium-server-standalone-2.41.0.jar -role node -nodeConfig c:\selenium\config.json 2 | -------------------------------------------------------------------------------- /vagrant_prepare.bat: -------------------------------------------------------------------------------- 1 | powershell -NonInteractive -Command Set-ExecutionPolicy Unrestricted 2 | powershell -NonInteractive -File C:\Temp\vagrant_prepare.ps1 3 | -------------------------------------------------------------------------------- /vagrant_prepare.ps1: -------------------------------------------------------------------------------- 1 | # Powershell Script to prepare the windows install to be used with selenium 2 | # Based on https://gist.github.com/tvjames/6750255 3 | 4 | Set-ExecutionPolicy -executionpolicy remotesigned -force 5 | 6 | # Step 1: Disable UAC 7 | New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -PropertyType DWord -Value 0 -Force | Out-Null 8 | Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green 9 | 10 | # Step 2: Disable IE ESC 11 | Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Value 0 | Out-Null 12 | Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Value 0 | Out-Null 13 | Stop-Process -Name Explorer | Out-Null 14 | Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green 15 | 16 | # Step 3: Disable the shutdown tracker 17 | # Reference: http://www.askvg.com/how-to-disable-remove-annoying-shutdown-event-tracker-in-windows-server-2003-2008/ 18 | If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability")) { 19 | New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" 20 | } 21 | New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonOn" -PropertyType DWord -Value 0 -Force -ErrorAction continue 22 | New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonUI" -PropertyType DWord -Value 0 -Force -ErrorAction continue 23 | Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonOn" -Value 0 24 | Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonUI" -Value 0 25 | Write-Host "Shutdown Tracker has been disabled." -ForegroundColor Green 26 | 27 | # Step 4: Disable Automatic Updates 28 | # Reference: http://www.benmorris.me/2012/05/1st-test-blog-post.html 29 | $AutoUpdate = (New-Object -com "Microsoft.Update.AutoUpdate").Settings 30 | $AutoUpdate.NotificationLevel = 1 31 | $AutoUpdate.Save() 32 | Write-Host "Windows Update has been disabled." -ForegroundColor Green 33 | 34 | # Step 5: Disable Complex Passwords 35 | # Reference: http://vlasenko.org/2011/04/27/removing-password-complexity-requirements-from-windows-server-2008-core/ 36 | $seccfg = [IO.Path]::GetTempFileName() 37 | secedit /export /cfg $seccfg 38 | (Get-Content $seccfg) | Foreach-Object {$_ -replace "PasswordComplexity\s*=\s*1", "PasswordComplexity=0"} | Set-Content $seccfg 39 | secedit /configure /db $env:windir\security\new.sdb /cfg $seccfg /areas SECURITYPOLICY 40 | del $seccfg 41 | Write-Host "Complex Passwords have been disabled." -ForegroundColor Green 42 | 43 | # Step 6: Enable Remote Desktop 44 | # Reference: http://social.technet.microsoft.com/Forums/windowsserver/en-US/323d6bab-e3a9-4d9d-8fa8-dc4277be1729/enable-remote-desktop-connections-with-powershell 45 | (Get-WmiObject Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices).SetAllowTsConnections(1,1) 46 | (Get-WmiObject -Class "Win32_TSGeneralSetting" -Namespace root\cimv2\TerminalServices -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0) 47 | 48 | # Step 7: Enable WinRM Control 49 | winrm quickconfig -q 50 | winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}' 51 | winrm set winrm/config '@{MaxTimeoutms="1800000"}' 52 | winrm set winrm/config/service '@{AllowUnencrypted="true"}' 53 | winrm set winrm/config/service/auth '@{Basic="true"}' 54 | Write-Host "WinRM has been configured and enabled." -ForegroundColor Green 55 | 56 | # Step 8: Disable Windows Firewall 57 | &netsh "advfirewall" "set" "allprofiles" "state" "off" 58 | Write-Host "Windows Firewall has been disabled." -ForegroundColor Green 59 | 60 | Write-Host "Restarting Computer." -ForegroundColor Yellow 61 | Restart-Computer 62 | --------------------------------------------------------------------------------