diff --git a/CustomMessage.xml b/CustomMessage.xml new file mode 100644 index 0000000..1b39fe2 --- /dev/null +++ b/CustomMessage.xml @@ -0,0 +1,9 @@ + + + We want to bring to your attention some important information. Please review the details below before contacting the Service Desk + Sent on behalf of the ICT Service Desk + Major IT Issues + We are currently experiencing problems with all our systems. We are drinking coffee will provide an update shortly. Thank you for your patience + Details + https://byteben.com + \ No newline at end of file diff --git a/InternetAccessProblems.xml b/InternetAccessProblems.xml new file mode 100644 index 0000000..4269ff6 --- /dev/null +++ b/InternetAccessProblems.xml @@ -0,0 +1,9 @@ + + + We want to bring to your attention some important information. Please review the details below before contacting the Service Desk + Sent on behalf of the ICT Service Desk + Internet Access Problems + We are currently experiencing intermittent problems with internet access. We are working with our service provider and will provide an update shortly + Details + https://byteben.com + \ No newline at end of file diff --git a/LeaveComputerSwitchedOn.xml b/LeaveComputerSwitchedOn.xml new file mode 100644 index 0000000..80ef55e --- /dev/null +++ b/LeaveComputerSwitchedOn.xml @@ -0,0 +1,9 @@ + + + We want to bring to your attention some important information. Please review the details below before contacting the Service Desk + Sent on behalf of the ICT Service Desk + Scheduled Mainteneance + We are working on your computer later. Please log off when you leave the office today but leave the computer on. Thank You + Details + https://byteben.com + \ No newline at end of file diff --git a/MicrosoftExchangeLimitedFunctionality.xml b/MicrosoftExchangeLimitedFunctionality.xml new file mode 100644 index 0000000..5f7a749 --- /dev/null +++ b/MicrosoftExchangeLimitedFunctionality.xml @@ -0,0 +1,9 @@ + + + We want to bring to your attention some important information. Please review the details below before contacting the Service Desk + Sent on behalf of the ICT Service Desk + Microsoft Exchange Limited Functionality + We are currently experiencing problems with the email system. We are working with our service provider and will provide an update shortly + Details + https://byteben.com + \ No newline at end of file diff --git a/PhoneSystemProblems.xml b/PhoneSystemProblems.xml new file mode 100644 index 0000000..2ed7398 --- /dev/null +++ b/PhoneSystemProblems.xml @@ -0,0 +1,9 @@ + + + We want to bring to your attention some important information. Please review the details below before contacting the Service Desk. + Sent on behalf of the ICT Service Desk + Phone System Problems + We are currently experiencing problems with our phone system. We are working with our service provider and will provide an update shortly. + Details + https://byteben.com + \ No newline at end of file diff --git a/Toast_Notify.ps1 b/Toast_Notify.ps1 new file mode 100644 index 0000000..50814e5 --- /dev/null +++ b/Toast_Notify.ps1 @@ -0,0 +1,167 @@ +<# +=========================================================================== +Created on: 22/07/2020 11:04 +Created by: Ben Whitmore +Filename: Toast_Notify.ps1 +=========================================================================== + +.SYNOPSIS +The purpose of the script is to create simple Toast Notifications in Windows 10 + +.DESCRIPTION +Toast_Notify.ps1 will read an XML file so Toast Notifications can be changed "on the fly" without having to repackage an application. The CustomMessage.xml file can be hosted on a fileshare. +To create a custom XML, copy CustomMessage.xml and edit the text you want to disaply in the toast notification. The following files should be present in the Script Directory + +Toast_Notify.ps1 +BadgeImage.jpg +HeroImage.jpg +CustomMessage.xml + +.PARAMETER XMLScriptDirSource +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 saem directory as the Toast_Notify.ps1 script + +.EXAMPLE +Toast_Notify.ps1 -XMLOtherSource "\\fileserverhome\xml\CustomMessage.xml" + +.EXAMPLE +Toast_Notify.ps1 -XMLSciptDirSource "CustomMessage5.xml" + +.EXAMPLE +Toast_Notify.ps1 +#> + +Param +( + [Parameter(Mandatory = $False)] + [String]$XMLScriptDirSource = "CustomMessage.xml", + [String]$XMLOtherSource + +) + +#Current Directory +$ScriptPath = $MyInvocation.MyCommand.Path +$CurrentDir = Split-Path $ScriptPath + +#Check if XML will come from the Script Source Directory or another source +If (!($PSBoundParameters.ContainsKey('XMLOtherSource') -eq $True)) { + $XMLPath = Join-Path $CurrentDir $XMLScriptDirSource +} +else { + $XMLPath = $XMLOtherSource +} + +#Test if XML exists +if (!(Test-Path -Path $XMLPath)) { + throw "$XMLPath is invalid." +} + +#Check XML is valid +$XMLToast = New-Object System.Xml.XmlDocument +try { + $XMLToast.Load((Get-ChildItem -Path $XMLPath).FullName) + $XMLValid = $True +} +catch [System.Xml.XmlException] { + Write-Verbose "$XMLPath : $($_.toString())" + $XMLValid = $False +} + +#Continue if XML is valid +If ($XMLValid -eq $True) { + + #Read XML Nodes + [XML]$Toast = Get-Content $XMLPath + + #Create Toast Variables + $ToastTitle = $XMLToast.ToastContent.ToastTitle + $Signature = $XMLToast.ToastContent.Signature + $EventTitle = $XMLToast.ToastContent.EventTitle + $EventText = $XMLToast.ToastContent.EventText + $ButtonTitle = $XMLToast.ToastContent.ButtonTitle + $ButtonAction = $XMLToast.ToastContent.ButtonAction + + #ToastDuration: Short = 7s, Long = 25s + $ToastDuration = "long" + + #Toast Time Format + $Time = Get-Date -Format HH:mm + + #Images + $BadgeImage = "file:///$CurrentDir/badgeimage.jpg" + $HeroImage = "file:///$CurrentDir/heroimage.jpg" + + #Set COM App ID > To bring a URL on button press to focus use a browser for the appid e.g. MSEdge + #$LauncherID = "Microsoft.SoftwareCenter.DesktopToasts" + #$LauncherID = "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe" + $Launcherid = "MSEdge" + + #Get last(current) logged on user + $LoggedOnUserPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" + If (!(Test-Path $LoggedOnUserPath)) { + Try { + $Firstname = $Null + } + Catch [System.Management.Automation.ItemNotFoundException] { + Write-Warning "$RegistryKey was not found." + } + Catch { + Write-Warning "Error $($error[0].Exception)." + } + } + else { + $User = Get-Itemproperty -Path $LoggedOnUserPath -Name "LastLoggedOnDisplayName" | Select-Object -ExpandProperty LastLoggedOnDisplayName + $DisplayName = $User.Split(" ") + $Firstname = $DisplayName[0] + } + + #Get Hour of Day and set Custom Hello + $Hour = (Get-Date).Hour + If ($Hour -lt 12) { $CustomHello = "Good Morning $($Firstname)" } + ElseIf ($Hour -gt 16) { $CustomHello = "Good Evening $($Firstname)" } + Else { $CustomHello = "Good Afternoon $($Firstname)" } + + #Load Assemblies + [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null + [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null + + #Build XML Template + [xml]$ToastTemplate = @" + + + + $CustomHello + $ToastTitle + $Signature + + + + + $EventTitle + + + + + $EventText + + + + + +"@ + + #Prepare XML + $ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New() + $ToastXml.LoadXml($ToastTemplate.OuterXml) + + #Prepare and Create Toast + $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) + [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($LauncherID).Show($ToastMessage) +} \ No newline at end of file diff --git a/badgeimage.jpg b/badgeimage.jpg new file mode 100644 index 0000000..9d2b54e Binary files /dev/null and b/badgeimage.jpg differ diff --git a/heroimage.jpg b/heroimage.jpg new file mode 100644 index 0000000..9ff75c9 Binary files /dev/null and b/heroimage.jpg differ