Sending Microsoft Notification via PSU

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)

Ok sorry, found out, that even if you indent the notification on ISE, i will get the error message :confused:

I’ve run into that before. For me, it’s normally been the closing "@ line where I indented but you aren’t supposed to for that. formatting the script in vscode normally fixes when i do that.

I stopped the experiment as it was no longer needed. I will continue to experiment a bit further for the future.