Minor Tweak for XML Append

Removed duplicate code in If/Else statement to add actions to $ToastTemplate XML
This commit is contained in:
Ben Whitmore 2021-01-10 22:48:34 +00:00
parent 9d70a0d842
commit cbb44e878f

View file

@ -35,12 +35,9 @@ BadgeImage.jpg
HeroImage.jpg HeroImage.jpg
CustomMessage.xml CustomMessage.xml
.PARAMETER XMLScriptDirSource .PARAMETER XMLSource
Specify the name of the XML file to read. The XML file must exist in the same directory as Toast_Notify.ps1. If no parameter is passed, it is assumed the XML file is called CustomMessage.xml. Specify the name of the XML file to read. The XML file must exist in the same directory as Toast_Notify.ps1. If no parameter is passed, it is assumed the XML file is called CustomMessage.xml.
.PARAMETER XMLOtherSource
Specify the location of the Custom XML file used for the Toast when it is not in the same directory as the Toast_Notify.ps1 script
.PARAMETER Snooze .PARAMETER Snooze
Add a snooze option to the Toast Add a snooze option to the Toast
@ -268,16 +265,17 @@ If (([System.Security.Principal.WindowsIdentity]::GetCurrent()).Name -eq $Logged
#If the Snooze parameter was passed, add additional XML elements to Toast #If the Snooze parameter was passed, add additional XML elements to Toast
If ($Snooze) { If ($Snooze) {
#Add Snooze Actions to $ToastTemplate #Define default and snooze actions to be added $ToastTemplate
$Action_Node = $ActionTemplateSnooze.toast.actions $Action_Node = $ActionTemplateSnooze.toast.actions
[void]$ToastTemplate.toast.AppendChild($ToastTemplate.ImportNode($Action_Node, $true))
} else {
#Add Actions to $ToastTemplate
$Action_Node = $ActionTemplate.toast.actions
[void]$ToastTemplate.toast.AppendChild($ToastTemplate.ImportNode($Action_Node, $true))
} }
else {
#Define default actions to be added $ToastTemplate
$Action_Node = $ActionTemplate.toast.actions
}
#Append actions to $ToastTemplate
[void]$ToastTemplate.toast.AppendChild($ToastTemplate.ImportNode($Action_Node, $true))
#Prepare XML #Prepare XML
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New() $ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()