Beispiel:
Function New-ToastMessage {
[cmdletBinding()]
Param(
[Parameter(Mandatory, Position = 0)]
[String]
$Title,
[Parameter(Mandatory,Position = 1)]
[String]
$Message,
[Parameter(Position = 2)]
[String]
$Logo = "C:\Windows\appcompat\UA\GenericApp.png",
[Parameter(Position = 3)]
[String]
$HintCrop = "circle"
)
$XmlString = @"
<toast>
<visual>
<binding template="ToastGeneric">
<text>$Title</text>
<text>$Message</text>
<image src="$Logo" placement="appLogoOverride" hint-crop="$HintCrop" />
</binding>
</visual>
<audio src="ms-winsoundevent:Notification.Default" />
</toast>
"@
$AppId = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
$null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
$ToastXml.LoadXml($XmlString)
$Toast = [Windows.UI.Notifications.ToastNotification]::New($ToastXml)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Show($Toast)
}
New-ToastMessage -Title "Test Title" -Message "Test Message"