# Detect installed Office version
$officeVersions = @("16.0", "15.0", "14.0")
$foundVersion = $null
foreach ($version in $officeVersions) {
$regPath = "HKCU:\Software\Microsoft\Office\$version\Outlook\Preferences"
if (Test-Path $regPath) {
$foundVersion = $version
break
}
}
if ($foundVersion -ne $null) {
$regPath = "HKCU:\Software\Microsoft\Office\$foundVersion\Outlook\Preferences"
$propertyName = "ShowAutoSug"
Write-Host "- Detected Office version: $foundVersion"
Write-Host "- Setting ShowAutoSug to 1 in $regPath"
# Set the ShowAutoSug registry value to enable Auto-Complete
Set-ItemProperty -Path $regPath -Name $propertyName -Value 1
# Double check the value
$valueName = "ShowAutoSug"
try {
$value = Get-ItemProperty -Path $regPath -Name $valueName -ErrorAction Stop
Write-Output "- After double checking, the value of '$valueName' is set to: $($value.$valueName)"
} catch {
Write-Output "The registry key or value '$valueName' does not exist under '$regPath'."
}
Write-Host "- Auto-Complete List has been enabled successfully. Moving on to the next registry location change."
} else {
Write-Host "No supported Office version found in registry."
}
# Updating the registry change in the 2nd location
$registryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Outlook\Preferences"
$propertyName = "ShowAutoSug"
# Check if the registry path exists
if (Test-Path $registryPath) {
# Set the ShowAutoSug value to 1
Set-ItemProperty -Path $registryPath -Name $propertyName -Value 1
Write-Output "- Successfully set '$propertyName' to 1 under '$registryPath'"
} else {
Write-Output "Registry path '$registryPath' does not exist."
}
# Double Checks what the value of the "Show Auto Suggestion" is in the Registry and writes it out for the end user
$registryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Outlook\Preferences"
$valueName = "ShowAutoSug"
try {
$value = Get-ItemProperty -Path $registryPath -Name $valueName -ErrorAction Stop
Write-Output "- After double checking, the value of '$valueName' is set to: $($value.$valueName). Auto suggestions should be working perfectly now.
Thank You!

"
} catch {
Write-Output "The registry key or value '$valueName' does not exist under '$registryPath'."
}