question

KedarTamboli-6326 avatar image
0 Votes"
KedarTamboli-6326 asked RoyLi-MSFT commented

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

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
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you please tell me what kind of app that you are developing? Is it a UWP app, WPF app, or WinForms app?

0 Votes 0 ·

I am writing the PowerShell script to push the windows toast notification on windows 10 workstations.... In that script, I need to add action button which will trigger some command, maybe PowerShell or basic command prompt commands etc...

0 Votes 0 ·

Since your issue is more related to PowerShell and has nothing to do with UWP development, I'll remove the UWP tag and make sure your issue is more focused on PowerShell.

0 Votes 0 ·

0 Answers