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

Kedar Tamboli 171 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 for business | Windows Server | User experience | PowerShell
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.