From e14f9469cb88893d3a262a958c6c38353d1fb2bc Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 27 Jan 2021 15:47:29 +0100 Subject: [PATCH] Move function declaration to top --- scripts/ADDS/payload/Apply-OVFProperties.ps1 | 46 ++++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts/ADDS/payload/Apply-OVFProperties.ps1 b/scripts/ADDS/payload/Apply-OVFProperties.ps1 index 73b83f9..dd57a3e 100644 --- a/scripts/ADDS/payload/Apply-OVFProperties.ps1 +++ b/scripts/ADDS/payload/Apply-OVFProperties.ps1 @@ -4,6 +4,29 @@ Param( # No parameters ) +Function New-ToastNotification { + Param( + [Parameter] + [string]$Stream = 'OVF Properties', + [Parameter(Mandatory)] + [string]$Title, + [Parameter(Mandatory)] + [string]$Text + ) + + $Template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02) + + $XML = [xml]$Template.GetXml() + $XML.SelectSingleNode("toast/visual/binding/text[@id='1']").InnerText = $Title + $XML.SelectSingleNode("toast/visual/binding/text[@id='2']").InnerText = $Text + + $SerializedXml = New-Object Windows.Data.Xml.Dom.XmlDocument + $SerializedXml.LoadXml($XML.OuterXml) + + $Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($Stream) + $Notifier.Show([Windows.UI.Notifications.ToastNotification]::new($SerializedXml)) +} + $NewEventLogSplat = @{ LogName = 'Application' Source = 'OVF-Properties' @@ -331,26 +354,3 @@ $WriteEventLogSplat = @{ } Write-EventLog @WriteEventLogSplat & schtasks.exe /Change /TN 'OVF-Properties' /DISABLE - -Function New-ToastNotification { - Param( - [Parameter] - [string]$Stream = 'OVF Properties', - [Parameter(Mandatory)] - [string]$Title, - [Parameter(Mandatory)] - [string]$Text - ) - - $Template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02) - - $XML = [xml]$Template.GetXml() - $XML.SelectSingleNode("toast/visual/binding/text[@id='1']").InnerText = $Title - $XML.SelectSingleNode("toast/visual/binding/text[@id='2']").InnerText = $Text - - $SerializedXml = New-Object Windows.Data.Xml.Dom.XmlDocument - $SerializedXml.LoadXml($XML.OuterXml) - - $Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($Stream) - $Notifier.Show([Windows.UI.Notifications.ToastNotification]::new($SerializedXml)) -} \ No newline at end of file