Background

I was asked by a customer to help figure out why their Outlook 2016 clients weren’t connecting to Exchange Online after their mailbox was moved from Exchange Server 2010. There were two reported problems with the Outlook clients after migration. The first issue was, the Outlook client would open but, would never connect to the mailbox. The second issue was, the Outlook client would get stuck at the loading window.

Our first troubleshooting step was open the Outlook connection status windows. Hold down the Crtl key and right click on the Outlook icon.

We noticed that the Outlook client was still trying to connect to the Exchange Server 2010 CAS servers and not the Exchange Online end-points.

This lead us to run, Fiddler, which confirmed that the Outlook 2016 client was getting stuck on the CAS server, even though the client was sending autodiscover requests to Office 365.

After doing some research we came across this Microsoft article, the covered our issue.

While we waited for the group policy to be deployed to all the users within the Organization, we needed a solution to implement the regkey to users that aren’t administrators on their location workstation. Since they are administrators, they are unable to open regedit on their computers.

Solution

A user does not need elevated privileges to edit the current user hive. Since regedit isn’t an option, PowerShell will do. We wrote a simple PowerShell script to solve the problem. You shouldn’t need to modify the script at all but, the script will write a log file to the user’s desktop. The output file will have two results, “has already been created” or “was created in path”. The “has already been created”, indicates the regkey existed before the script was executed. The “was created in path” indicates the file was created successfully.

Script

#Log file will be created on the user desktop with the name OutlookKey.Log
$DesktopPath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Desktop)
$logfile = (“$DesktopPath\OutlookKey.log”)
$registryPath = “HKCU:\Software\Microsoft\Exchange”
$Name = “AlwaysUseMSOAuthForAutoDiscover”
$Value = 1

#Function that creates the log file and manages log file entries
function log {
param (
[String]$text,
[Switch]$fout
)
ac $logfile $text
if ($showConsoleOutput){
if ($fout){
Write-Host $text -ForegroundColor Red
}else{
Write-Host $text -ForegroundColor Green
}
}
}
log -text”—–$(Get-Date) Services – $($env:USERNAME) on $($env:COMPUTERNAME) starting—–”

#Connect to the Exchange path an loop through each key to validate if the AlwaysUseMSOAuthForAutoDiscover key has already been created. If not create the key
set-location -path Registry::HKEY_CURRENT_USER\Software\Microsoft\Exchange
$List = Get-item .
Foreach ($File in $List) {
If ($File.Property -eq “AlwaysUseMSOAuthForAutoDiscover”){
Write-Host “RegKey $File.Property has already been created”
Get-item .
log -text”—–RegKey $File.Property has already been created”
}
Else {
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force
log -text”—–RegKey $name was created in path $registryPath with the value of $value”
}
}