Detection:
# Detection script for HideNewOutlookToggle registry key
$regPath = "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\General"
$regName = "HideNewOutlookToggle"
$regValue = 1
try {
if ((Test-Path -Path $regPath) -and
((Get-ItemProperty -Path $regPath -Name $regName -ErrorAction SilentlyContinue).$regName -eq $regValue)) {
Write-Host "Compliant: HideNewOutlookToggle registry key found with correct value."
exit 0
} else {
Write-Host "Non-compliant: HideNewOutlookToggle registry key not found or has incorrect value."
exit 1
}
} catch {
Write-Host "Error checking registry key: $_"
exit 1
}
Remediation:
# Remediation script for HideNewOutlookToggle registry key
$regPath = "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\General"
$regName = "HideNewOutlookToggle"
$regValue = 1
try {
New-ItemProperty -Path $regPath -Name $regName -Value $regValue -PropertyType DWORD -Force | Out-Null
$outlookApp = Get-AppxPackage -Name *Outlook* | Where-Object { $_.Name -like "*Microsoft.Outlook*" }
Remove-AppxPackage -Package $outlookApp.PackageFullName
Write-Host "Successfully Removed Outlook (new) and set HideNewOutlookToggle registry key to value 1."
exit 0
} catch {
Write-Host "Failed to set registry key: $_"
exit 1
}