Need help with Win10 automation using PowerShell script. Want notifs to be off when external display is connected.

Manasaurus

Recruit
I wanted the notifications in windows 10 to be turned off whenever I connect it to an external display using HDMI, without using an external application. This is what I have been able to come up so far:

- used Task Scheduler to create a task
- checked the Event Viewer when the external display was connected. The details came out to be -
Log: Microsoft-Windows-DeviceSetupManager/Admin
Source: DeviceSetupManager
Event ID: 112
- Now had to write a script to run when the event was triggered
- ChatGPT suggested a powershell script but it doesnt seem to work.
- I have checked the registry editor to figure out what needed to be done but can't figure it out.

Any suggestions? Or should I scrape the whole thing off and try a different approach? Here's the code chatGPT gave:




# Disable Windows 10 notifications
# Check if running with administrator privileges
$isAdmin = ([Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544"
if (-not $isAdmin) {
Write-Host "Please run this script with administrator privileges."
exit
}
# Disable notifications
Write-Host "Disabling Windows 10 notifications..."
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" -Name ToastEnabled -Value 0 -PropertyType DWORD -Force | Out-Null
Write-Host "Notifications disabled successfully."
# Prompt to restart Explorer for changes to take effect
$restartExplorer = Read-Host "Do you want to restart Explorer to apply changes? (Y/N)"
if ($restartExplorer -eq 'Y' -or $restartExplorer -eq 'y') {
Stop-Process -Name explorer -Force
Start-Process explorer
Write-Host "Explorer restarted."
} else {
Write-Host "Changes will take effect after the next system restart or Explorer restart."
}
 
Isn't this a standard feature on Windows 10? Here's a how to I found online for it; Windows 11 has it too, but in a slightly different spot. This should work unless you want to do this even when extending your display, which shouldn't be necessary since your notifications should only show up on the main display.
 
Isn't this a standard feature on Windows 10? Here's a how to I found online for it; Windows 11 has it too, but in a slightly different spot. This should work unless you want to do this even when extending your display, which shouldn't be necessary since your notifications should only show up on the main display.
um.. yes I should have mentioned it that I am changing the main display to a external and not duplicating it.
 
Well, let's get the obvious thing out of the way, in Task scheduler under which account are you running the task under? is it an admin account? do you have the correct options ticked?
the options being:
Change the user account to a user that has admin rights on the PC
Run with highest privileges
Change "Configure for:" to "Windows 10"

1705929452606.png
 
Well, let's get the obvious thing out of the way, in Task scheduler under which account are you running the task under? is it an admin account? do you have the correct options ticked?
the options being:
Change the user account to a user that has admin rights on the PC
Run with highest privileges
Change "Configure for:" to "Windows 10"
I appreciate the input, but I decided to scap the idea altogether. theres a feature of focus assist on win10 that allows me to stop the notifs when full screen is enabled. while its not exactly what I was trying to do, it is good enough for now since I mostly watch stuff when connected to the second screen.
 
I appreciate the input, but I decided to scap the idea altogether. theres a feature of focus assist on win10 that allows me to stop the notifs when full screen is enabled. while its not exactly what I was trying to do, it is good enough for now since I mostly watch stuff when connected to the second screen.

in case you do try to do this in the future, try googling, the original script on the forum may have some issues for sure, plus you get the comments etc.
 
Back
Top