Created
January 6, 2025 10:52
-
-
Save mattbalzan/ef27f1d93c9dd8c39cde472a9b6e08cd to your computer and use it in GitHub Desktop.
Windows Toast Message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Windows Toast Message ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
function Toast($Title,$msgText){ | |
# Main script | |
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null | |
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null | |
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null | |
$APP_ID = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe' | |
$template = @" | |
<toast> | |
<visual> | |
<binding template="ToastText02"> | |
<text id="1">$Title</text> | |
<text id="2">$msgText</text> | |
</binding> | |
</visual> | |
</toast> | |
"@ | |
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument | |
$xml.LoadXml($template) | |
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml | |
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID).Show($toast) | |
} | |
Toast Hello Howdy! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment