Glenn M
asked on
Import content of text file into powershell script before executing?
I need a way to simply the <text> portion of my Powershell Script that makes a TOAST command. I'm trying to prevent people from making mistakes to the script when being edited.
Is there a way to import the body of a text file and have it imported into the PowerShell script where you find <text> *** </text> ?
Here is my PS so far:
Is there a way to import the body of a text file and have it imported into the PowerShell script where you find <text> *** </text> ?
Here is my PS so far:
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
#Gets the Template XML so we can manipulate the values
[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())
[xml]$ToastTemplate = @"
<toast launch="action=viewAlarm&alarmId=3" scenario="alarm">
<visual>
<binding template="ToastGeneric">
<text>* Notification *</text>
<text>ALERT - Faxing Services are in the Cloud, It's Raining and therefore could faxing no longer works. Stay Tuned for more Information!</text>
<image placement="appLogoOverride" hint-crop="circle" src="https://picsum.photos/64?image=000"/>
<image placement="hero" src="http://finalbca.16mb.com/noti2.png"/>
</binding>
</visual>
<actions>
<action
activationType="system"
arguments="snooze"
content=""/>
<action
activationType="background"
arguments="dismiss"
content="Dismiss"/>
</actions>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)
$notify.Show($ToastXml)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER