Attempt to fix issue 517
This commit is contained in:
		| @@ -1,6 +1,8 @@ | ||||
| # Purpose: Joins a Windows host to the windomain.local domain which was created with "create-domain.ps1". | ||||
| # Source: https://github.com/StefanScherer/adfs2 | ||||
|  | ||||
| $hostsFile = "c:\Windows\System32\drivers\etc\hosts" | ||||
|  | ||||
| Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Joining the domain..." | ||||
|  | ||||
| Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) First, set DNS to DC to join the domain..." | ||||
| @@ -9,6 +11,11 @@ $adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.I | ||||
| # Don't do this in Azure. If the network adatper description contains "Hyper-V", this won't apply changes. | ||||
| $adapters | ForEach-Object {if (!($_.Description).Contains("Hyper-V")) {$_.SetDNSServerSearchOrder($newDNSServers)}} | ||||
|  | ||||
| # Hardcoding DNS domain name in hosts file to sidestep any DNS issues | ||||
| If (!(Select-String -Path $hostsFile -Pattern "192.168.38.102")) { | ||||
|   Add-Content $hostsFile "        192.168.38.102    windomain.local" | ||||
| } | ||||
|  | ||||
| Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Now join the domain..." | ||||
| $hostname = $(hostname) | ||||
| $user = "windomain.local\vagrant" | ||||
| @@ -18,6 +25,10 @@ $DomainCred = New-Object System.Management.Automation.PSCredential $user, $pass | ||||
| # Place the computer in the correct OU based on hostname | ||||
| If ($hostname -eq "wef") { | ||||
|   Add-Computer -DomainName "windomain.local" -credential $DomainCred -OUPath "ou=Servers,dc=windomain,dc=local" -PassThru | ||||
|   # Attempt to fix Issue #517 | ||||
|   Set-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control' -Name 'WaitToKillServiceTimeout' -Value '500' -Type String -Force -ea SilentlyContinue | ||||
|   New-ItemProperty -LiteralPath 'HKCU:\Control Panel\Desktop' -Name 'AutoEndTasks' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue | ||||
|   Set-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\SessionManager\Power' -Name 'HiberbootEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue | ||||
| } ElseIf ($hostname -eq "win10") { | ||||
|   Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Adding Win10 to the domain. Sometimes this step times out. If that happens, just run 'vagrant reload win10 --provision'" #debug | ||||
|   Add-Computer -DomainName "windomain.local" -credential $DomainCred -OUPath "ou=Workstations,dc=windomain,dc=local" | ||||
| @@ -25,6 +36,7 @@ If ($hostname -eq "wef") { | ||||
|   Add-Computer -DomainName "windomain.local" -credential $DomainCred -PassThru | ||||
| } | ||||
|  | ||||
| # Set auto login | ||||
| Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -Value 1 | ||||
| Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUserName -Value "vagrant" | ||||
| Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -Value "vagrant" | ||||
| @@ -36,8 +48,6 @@ Stop-Service wuauserv | ||||
| Set-Service TrustedInstaller -StartupType Disabled | ||||
| Stop-Service TrustedInstaller | ||||
|  | ||||
|  | ||||
|  | ||||
| # Uninstall Windows Defender from WEF | ||||
| # This command isn't supported on WIN10 | ||||
| If ($hostname -ne "win10" -And (Get-Service -Name WinDefend -ErrorAction SilentlyContinue).status -eq 'Running') { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Chris Long
					Chris Long