backup/Backup-NotificationTemplates.ps1
|
#Requires -Version 7.0 function Backup-NotificationTemplates { [CmdletBinding()] param( [Parameter(Mandatory)] [string]$BackupPath, [Parameter(Mandatory)] [SecureString]$Token, [hashtable]$ScopeTagMap = @{} ) try { $folder = Join-Path $BackupPath 'Compliance Policies' 'Message Templates' $uri = '/beta/deviceManagement/notificationMessageTemplates?$expand=localizedNotificationMessages' $items = Invoke-GraphRequest2 -Uri $uri -Token $Token foreach ($item in $items) { if ($item.displayName -eq 'EnrollmentNotificationInternalMEO') { continue } # clean volatile keys from localized notification messages if ($item.localizedNotificationMessages) { $item.localizedNotificationMessages = @($item.localizedNotificationMessages | ForEach-Object { Remove-VolatileKeys -InputObject $_ }) } $clean = Remove-VolatileKeys -InputObject $item Save-BackupItem -Item $clean -Folder $folder -ScopeTagMap $ScopeTagMap } Write-Verbose "backed up notification templates to $folder" } catch { Write-Error "failed to backup notification templates: $_" return } } Export-ModuleMember -Function Backup-NotificationTemplates |