Skip to content

Instantly share code, notes, and snippets.

@twilight-sparkle-irl
Created November 2, 2018 03:24
Show Gist options
  • Select an option

  • Save twilight-sparkle-irl/ad68e30b086dcf29c54255cf712a83c3 to your computer and use it in GitHub Desktop.

Select an option

Save twilight-sparkle-irl/ad68e30b086dcf29c54255cf712a83c3 to your computer and use it in GitHub Desktop.
invoke-windowsdefendertoast
Function Invoke-WindowsDefenderToast {
Param (
[Parameter(Mandatory=$True)]
[string]$Message,
[Parameter()]
[string]$Title="Virus & threat protection"
)
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>$Title
&#xa0;</text>
<text>$Message</text>
</binding>
</visual>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Microsoft.Windows.SecHealthUI_cw5n1h2txyewy!SecHealthUI")
$notify.Show($ToastXml)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment