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

Kedar Tamboli 166 Reputation points
2021-09-01T12:13:09.383+00:00

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 = @"
<toast>
<visual>
<binding template="ToastGeneric">
<text>Pledge Notification</text>
<text placement="attribution">via IT Team</text>
<group>
<subgroup>
<text hint-style="body" hint-wrap="true" >Dont miss to take Pledge today! Click on Pledge button below!</text>
</subgroup>
</group>
</binding>
</visual>
<actions>
<action activationType="protocol" arguments="$PledgeURL" content="Pledge URL" />
<action activationType="foreground" arguments="$DismissAction" content="Dismiss" />
</actions>
</toast>
"@


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,462 questions
{count} votes