Skip to content

Instantly share code, notes, and snippets.

@pstakuu
Created November 1, 2022 15:02
Show Gist options
  • Select an option

  • Save pstakuu/478b2cf70b951cb4221aa0b772bd0e9f to your computer and use it in GitHub Desktop.

Select an option

Save pstakuu/478b2cf70b951cb4221aa0b772bd0e9f to your computer and use it in GitHub Desktop.
HKCU changes as admin - specifically this one for hiding ads in Outlook
$loggedonUser = get-wmiobject -Class win32_computersystem |select username
$objuser = new-object System.Security.Principal.NTAccount($loggedonUser.username)
$userdata = $objuser.Translate([System.Security.Principal.SecurityIdentifier])
Set-ItemProperty "registry::hkey_users\$($userdata.value)\Software\Microsoft\Office\16.0\Common\TargetedMessagingService\MessageMetadata\*MsgId:BizBar" -Name AppIdOnAction -Value 6
Set-ItemProperty "registry::hkey_users\$($userdata.value)\Software\Microsoft\Office\16.0\Common\TargetedMessagingService\MessageMetadata\*MsgId:BizBar" -Name SetUserAction -Value 2
#current user changes as admin: https://stackoverflow.com/questions/66066661/how-to-edit-hkcu-values-with-powershell#:~:text=When%20running%20an%20elevated%20PowerShell%2C%20the%20user%20specific,SID%3E....%20For%20example%3A%20Get-ItemProperty%20-Path%20%22registry%3A%3Ahkey_users%24%20%28%24strSID.Value%29SoftwarePoliciesMicrosoftWindowsControl%20PanelDesktop%22
#reg settings: https://community.spiceworks.com/topic/2276029-outlook-displays-take-your-outlook-anywhere-how-do-i-stop-these-messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment