Windows Toast Notification Action to initiate PowerShell Command....possible?

Kedar Tamboli 166 Reputation points

Hello All,

I want to create Windows Toast Notification with Action button. If I click an action button then it should trigger PowerShell command. Is this possible?

In below code, clicking dismiss button, DismissAction should invoke PS Command : {New-Item -Path 'C:\DismissFile.txt' -ItemType File -Force}

(File to create as to stop the recurrence of the notification)

I am writing PS script for that however stuck at this step.

Below is the Toast Code:

Build XML Template

[xml]$ToastTemplate88 = @"
<binding template="ToastGeneric">
<text>Pledge Notification</text>
<text placement="attribution">via IT Team</text>
<text hint-style="body" hint-wrap="true" >Dont miss to take Pledge today! Click on Pledge button below!</text>
<action activationType="protocol" arguments="$PledgeURL" content="Pledge URL" />
<action activationType="foreground" arguments="$DismissAction" content="Dismiss" />

Any similar has anyone tried. Please suggest way forward.

Thanks in advance!

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,433 questions
{count} votes