diff --git a/New-ToastNotification.ps1 b/New-ToastNotification.ps1 index 1ea1cab..ed14a64 100644 --- a/New-ToastNotification.ps1 +++ b/New-ToastNotification.ps1 @@ -1343,6 +1343,7 @@ if(-NOT[string]::IsNullOrEmpty($Xml)) { } $Scenario = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Scenario'} | Select-Object -ExpandProperty 'Type' $Action = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action'} | Select-Object -ExpandProperty 'Value' + $Action2 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action2'} | Select-Object -ExpandProperty 'Value' $GreetGivenName = $Xml.Configuration.Text | Where-Object {$_.Option -like 'GreetGivenName'} | Select-Object -ExpandProperty 'Enabled' $MultiLanguageSupport = $Xml.Configuration.Text | Where-Object {$_.Option -like 'MultiLanguageSupport'} | Select-Object -ExpandProperty 'Enabled' # Load Custom Action Details @@ -1351,6 +1352,7 @@ if(-NOT[string]::IsNullOrEmpty($Xml)) { $CustomActionName = $Xml.Configuration.CustomActions.Action.Name # Load Toast Notification buttons $ActionButtonEnabled = $Xml.Configuration.Option | Where-Object {$_.Name -like 'ActionButton'} | Select-Object -ExpandProperty 'Enabled' + $Action2ButtonEnabled = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action2Button'} | Select-Object -ExpandProperty 'Enabled' $DismissButtonEnabled = $Xml.Configuration.Option | Where-Object {$_.Name -like 'DismissButton'} | Select-Object -ExpandProperty 'Enabled' $SnoozeButtonEnabled = $Xml.Configuration.Option | Where-Object {$_.Name -like 'SnoozeButton'} | Select-Object -ExpandProperty 'Enabled' # Multi language support @@ -1381,6 +1383,7 @@ if(-NOT[string]::IsNullOrEmpty($Xml)) { $ADPasswordExpirationTextValue = $XmlLang.Text | Where-Object {$_.Name -like 'ADPasswordExpirationText'} | Select-Object -ExpandProperty '#text' $CustomAudioTextToSpeech = $XmlLang.Text | Where-Object {$_.Name -like 'CustomAudio'} | Select-Object -ExpandProperty '#text' $ActionButtonContent = $XmlLang.Text | Where-Object {$_.Name -like 'ActionButton'} | Select-Object -ExpandProperty '#text' + $Action2ButtonContent = $XmlLang.Text | Where-Object {$_.Name -like 'Action2Button'} | Select-Object -ExpandProperty '#text' $DismissButtonContent = $XmlLang.Text | Where-Object {$_.Name -like 'DismissButton'} | Select-Object -ExpandProperty '#text' $SnoozeButtonContent = $XmlLang.Text | Where-Object {$_.Name -like 'SnoozeButton'} | Select-Object -ExpandProperty '#text' $AttributionText = $XmlLang.Text | Where-Object {$_.Name -like 'AttributionText'} | Select-Object -ExpandProperty '#text' @@ -1585,6 +1588,12 @@ if (($CustomActionsEnabled -eq "True") -AND (($UpgradeOS -eq "True") -or ($Pendi Write-Log -Level Error -Message "You should only enable one of the features or CustomActions" Exit 1 } +if (($ActionButtonEnabled -ne "True") -AND ($Action2ButtonEnabled -eq "True")){ + Write-Log -Level Error -Message "Error. Conflicting selection in the $Config file" + Write-Log -Level Error -Message "Error. You can't have Action2Button enabled and ActionButton not enabled." + Write-Log -Level Error -Message "ActionButton must be enabled for Action2Button to be enabled. Check your config" + Exit 1 +} # Downloading images into user's temp folder if images are hosted online if (($LogoImageFileName.StartsWith("https://")) -OR ($LogoImageFileName.StartsWith("http://"))) { @@ -1800,7 +1809,7 @@ if ($GreetGivenName -eq "True") { # Formatting the toast notification XML # Create the default toast notification XML with action button and dismiss button -if (($ActionButtonEnabled -eq "True") -AND ($DismissButtonEnabled -eq "True")) { +if (($ActionButtonEnabled -eq "True") -AND ($Action2ButtonEnabled -ne "True") -AND ($DismissButtonEnabled -eq "True")) { Write-Log -Message "Creating the xml for displaying both action button and dismiss button" [xml]$Toast = @" @@ -1835,8 +1844,45 @@ if (($ActionButtonEnabled -eq "True") -AND ($DismissButtonEnabled -eq "True")) { "@ } +# Create the default toast notification XML with action button and dismiss button +if (($Action2ButtonEnabled -eq "True") -AND ($ActionButtonEnabled -eq "True") -AND ($DismissButtonEnabled -eq "True")) { + Write-Log -Message "Creating the xml for displaying both action button and dismiss button" +[xml]$Toast = @" + + + + + + $AttributionText + $HeaderText + + + $TitleText + + + + + $BodyText1 + + + + + $BodyText2 + + + + + + + + + + +"@ +} + # NO action button and NO dismiss button -if (($ActionButtonEnabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) { +if (($ActionButtonEnabled -ne "True") -AND ($Action2ButtonEnabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) { Write-Log -Message "Creating the xml for no action button and no dismiss button" [xml]$Toast = @" @@ -1870,7 +1916,7 @@ if (($ActionButtonEnabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) { } # Action button and NO dismiss button -if (($ActionButtonEnabled -eq "True") -AND ($DismissButtonEnabled -ne "True")) { +if (($ActionButtonEnabled -eq "True") -AND ($Action2ButtonEnabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) { Write-Log -Message "Creating the xml for no dismiss button" [xml]$Toast = @" @@ -1905,7 +1951,7 @@ if (($ActionButtonEnabled -eq "True") -AND ($DismissButtonEnabled -ne "True")) { } # Dismiss button and NO action button -if (($ActionButtonEnabled -ne "True") -AND ($DismissButtonEnabled -eq "True")) { +if (($ActionButtonEnabled -ne "True") -AND ($Action2ButtonEnabled -ne "True") -AND ($DismissButtonEnabled -eq "True")) { Write-Log -Message "Creating the xml for no action button" [xml]$Toast = @" diff --git a/config-toast-custom.xml b/config-toast-custom.xml index 134e0d3..fd9658d 100644 --- a/config-toast-custom.xml +++ b/config-toast-custom.xml @@ -24,12 +24,12 @@