Product: PowerShell Universal
Version: 5.5.1
Hi everyone,
I’m currently working on a small project and hope someone can help me. I would like to send a Microsoft notification to a target computer via PSSession (invoke-command). However, when I insert and indent my notification, I get the following errors: “White space is not allowed before the string terminator” and “Missing closing ‘}’ in statement block or type definition.” Any Idea how I can fix it? When I start this Notificationscript via ISE, there is no problem. My problem is, that I cant save the PSU Script because of these warnings.
$notification = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Softwarecenter")
$xml = @"
<toast>
<visual>
<binding template="ToastText02">
<text id="1">Systemneustart erforderlich</text>
<text id="2">Ihr System benötigt einen Neustart. Bitte führen Sie zeitnah einen Neustart durch, um wichtige Änderungen zu übernehmen.</text>
</binding>
</visual>
</toast>
"@
# Erstellen des Windows-spezifischen XML-Dokuments
$xmlDoc = New-Object Windows.Data.Xml.Dom.XmlDocument
$xmlDoc.LoadXml($xml)
# Erstellen und Anzeigen der Toast-Benachrichtigung
$toast = [Windows.UI.Notifications.ToastNotification]::new($xmlDoc)
$notification.Show($toast)