Enforcing notifications from specific applications to be enabled

Robert Polenius Andersson 121 Reputation points
2021-03-15T09:17:17.287+00:00

Hi,

We are looking to enforce notifications from specific aplications to be enabled.

"Settings" -> "System" -> "Notifications & actions" -> "Get notifications from these senders".

We have tried running the following to enable notifications for Software Center:

Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SoftwareCenter.DesktopToasts" -Name Enabled -Value 1 -Force

Get-Service -Name WpnUserService* | Restart-Service -Force

The settings GUI updates and shows the setting as enabled but toasts from Software Center still doesn't show.

We have tried finding any registry keys via procmon but with no success.

We can't seem to find any policies that are able to do this.

Help please!

Thanks in advance.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,172 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,087 questions
Windows 10 Setup
Windows 10 Setup
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
1,920 questions
{count} vote

Accepted answer
  1. Robert Polenius Andersson 121 Reputation points
    2021-10-25T06:57:07.8+00:00

    Hi everyone!

    I actually solved this with the help from @Lockner, Shawn (CORP) s comment.
    Sorry that I haven't posted.

    I created the script below and integrated it as a CI/CB in MECM to enable notifications for Powershell but it can easily be modified for other programs.

    #####Author: Robert Polenius Andersson  
    ####Enable disabled notifications  
    ###Script is set to enable notifications for Powershell but can be modified to work with any application that are using the Windows Notification framework  
    ###REQUIREMENTS  
    ##Modules: PSSQLite  
      
    try{  
        ##Database  
        #Import SQLite module  
        Import-Module PSSQLite  
      
        #Set DBPath  
        $DatabasePath = "$env:LOCALAPPDATA\Microsoft\Windows\Notifications\wpndatabase.db"  
      
        #Define select query  
        $SelectQuery = "  
        SELECT HS.HandlerId, HS.SettingKey, HS.Value  
        FROM NotificationHandler AS NH  
        INNER JOIN HandlerSettings AS HS ON NH.RecordId = HS.HandlerID  
        WHERE NH.PrimaryId LIKE '%powershell.exe'  
        AND HS.SettingKey = 's:toast'  
        "  
      
        #Invoke selectquery  
        $NotificationSettings = Invoke-SqliteQuery -DataSource $DatabasePath -Query $SelectQuery  
      
        #If the setting are wrong  
        if($NotificationSettings.Value -ne 1){  
            #Create update query  
            $UpdateQuery = "  
            UPDATE HandlerSettings  
            SET Value = 1  
            WHERE HandlerId = '$($NotificationSettings.HandlerId)' AND SettingKey = 's:toast'  
            "  
            #Invoke updatequery  
            Invoke-SqliteQuery -DataSource $DatabasePath -Query $UpdateQuery  
        }  
      
        ##Registry  
        #Get registry path for application Powershell  
        $RegistryPath = (Get-ChildItem -Recurse -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings" | Where-Object -Property Name -Like '*powershell.exe*' | Select-Object -ExpandProperty Name).Replace('HKEY_CURRENT_USER','HKCU:')  
      
        #Get current value for Enabled  
        $Enabled = Get-ItemProperty -Path $RegistryPath -Name "Enabled" | Select-Object -ExpandProperty Enabled  
      
        #If the value are wrong  
        if($Enabled -ne 1){  
            #Update registry  
            Set-ItemProperty -Path $RegistryPath -Name "Enabled" -Value 1 -Force  
        }  
        return 0  
    }catch{  
        $LogFile = "C:\Powershell\Log\PowershellNotifications.log"  
        if(!(Test-Path $LogFile -ErrorAction SilentlyContinue)){  
            New-Item -Path $LogFile  
        }  
        "$(Get-Date) | RemediationScript | ERROR: $($_)" | Out-File $LogFile -Append  
        return $_  
    }  
    
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. samet karanfil 11 Reputation points
    2021-10-24T18:21:31.503+00:00

    hi all,
    you can do this commands for powershell but old notifications clear all :)
    Get-Service -Name WpnUserService_f5c77c | stop-Service
    Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}" -Recurse
    Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications\Backup{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}" -Recurse
    C:\Users\user\AppData\Local\Microsoft\Windows\Notifications - delete db files
    Get-Service -Name WpnUserService_f5c77c | start-Service

    2 people found this answer helpful.

  2. Jenny Feng 14,101 Reputation points
    2021-03-16T07:31:13.373+00:00

    Hi,
    I am afraid that we can’t enforce notifications from specific applications in Windows.
    Because the actions (notifications) are meant to be displayed to the user until they take action.

    Or you could try the method mentioned in the following link:
    https://www.tenforums.com/tutorials/4111-turn-off-notifications-apps-senders-windows-10-a.html
    Please note: Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.
    Hope above information can help you.

    ============================================
    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Berndt Schwarzinger 0 Reputation points Microsoft Employee
    2023-04-13T14:27:41.71+00:00

    @samet karanfil thank you!! Your suggestion actually solved my issue. I was not able to turn on BurntToast notifications again, after disabling them in the Toast Popup. PowerShell Notifications are not listed in the Windows 11 Settings, and re-enabling PowerShell notifications in the Registry ( Key "Enabled" = 1 ) did not work as well. You have a few syntax issues in your commands tho, I put the fixed version in a PS script:

    Get-Service -Name WpnUserService* | stop-Service
    
    Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}" -Recurse
    
    Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications\Backup\{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}" -Recurse
    
    del C:\Users\<YOURUSERNAME!!!>\AppData\Local\Microsoft\Windows\Notifications\*
    
    Get-Service -Name WpnUserService* | start-Service
    

    Again - thanks!!!

    0 comments No comments