|
# AAD Connect installation with Health on proxy enabled machine |
|
|
|
# Disable IES |
|
$AdminKey = “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}” |
|
$UserKey = “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}” |
|
Set-ItemProperty -Path $AdminKey -Name “IsInstalled” -Value 0 |
|
Set-ItemProperty -Path $UserKey -Name “IsInstalled” -Value 0 |
|
|
|
|
|
# Authenticated |
|
$userProxyServer = "squid02.corp.contoso.com" |
|
$userProxyPort = 3128 |
|
|
|
# no auth |
|
$systemProxyServer = "squid01.corp.contoso.com" |
|
$systemProxyPort = 3128 |
|
|
|
# Set user proxy |
|
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -Value "$($userProxyServer):$($userProxyPort)" |
|
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -Value 1 |
|
|
|
# Update .NET machine.config file to use proxy |
|
$machineConfigFile = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config" |
|
[System.Xml.XmlDocument]$machineConfig = New-Object System.Xml.XmlDocument |
|
$machineConfig.Load($machineConfigFile) |
|
|
|
[xml]$machineConfig = Get-Content $machineConfigFile |
|
$node = $machineConfig.SelectSingleNode("/configuration/system.net") |
|
if(-not $node) { |
|
$configurationNode = $machineConfig.SelectSingleNode("/configuration") |
|
$node = $machineConfig.CreateElement("system.net") |
|
$configurationNode.AppendChild($node) | Out-Null |
|
} |
|
|
|
# Remove existing proxy configurations |
|
$proxyConfigs = $node.SelectNodes("defaultProxy") |
|
foreach($proxy in $proxyConfigs) { |
|
$node.RemoveChild($proxy) |
|
} |
|
|
|
# set our |
|
[xml]$proxyXml = @" |
|
<defaultProxy> |
|
<proxy |
|
usesystemdefault="true" |
|
proxyaddress="http://$($systemProxyServer):$($systemProxyPort)" |
|
bypassonlocal="true" |
|
/> |
|
</defaultProxy> |
|
"@ |
|
$node.AppendChild($machineConfig.ImportNode($proxyXml.defaultProxy, $true)) | Out-Null |
|
|
|
# Save changes |
|
$machineConfig.Save($machineConfigFile) |
|
|
|
# after restart is important to check if computer sees network connectivity |
|
# install aad connect |
|
# registration failed for aad health is expected if proxy auth is used |
|
|
|
Set-AzureADConnectHealthProxySettings -HttpsProxyAddress "$($systemProxyServer):$($systemProxyPort)" |
|
Restart-Service AzureADConnectHealth* |
|
|
|
# and finally complete aad health agent registration |
|
# to be sure in new powershell admin window run this command |
|
Register-AzureADConnectHealthSyncAgent -AttributeFiltering $false -StagingMode $false |
Thank you Vladimír! I needed to revert from NAT to a proxy server due to a fiber cut to our location. Will need to speed up the AD Connect migration to a Azure VM.