-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBackup-TeamsEV.ps1
executable file
·55 lines (45 loc) · 2.22 KB
/
Backup-TeamsEV.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<#
.SYNOPSIS
A script to automatically backup a Microsoft Teams Enterprise Voice configuration.
.DESCRIPTION
Automates the backup of Microsoft Teams Enterprise Voice normalization rules, dialplans, voice policies, voice routes, PSTN usages and PSTN GW translation rules for various countries.
.PARAMETER OverrideAdminDomain
OPTIONAL: The FQDN your Office365 tenant. Use if your admin account is not in the same domain as your tenant (ie. doesn't use a @tenantname.onmicrosoft.com address)
.NOTES
Version 1.10
Build: Feb 04, 2020
Copyright © 2020 Ken Lasko
https://www.ucdialplans.com
#>
[CmdletBinding(ConfirmImpact = 'None')]
param
(
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$OverrideAdminDomain
)
$Filenames = 'Dialplans.txt', 'VoiceRoutes.txt', 'VoiceRoutingPolicies.txt', 'PSTNUsages.txt', 'TranslationRules.txt', 'PSTNGateways.txt'
Try {
Connect-MicrosoftTeams
}
Catch {
Write-Warning 'Microsoft Teams PowerShell module not installed. Please install via Install-Module MicrosoftTeams, then run the script again.'
Break
}
Try {
$null = (Get-CsTenantDialPlan | ConvertTo-Json | Out-File -FilePath Dialplans.txt -Force -Encoding utf8)
$null = (Get-CsOnlineVoiceRoute | ConvertTo-Json | Out-File -FilePath VoiceRoutes.txt -Force -Encoding utf8)
$null = (Get-CsOnlineVoiceRoutingPolicy | ConvertTo-Json | Out-File -FilePath VoiceRoutingPolicies.txt -Force -Encoding utf8)
$null = (Get-CsOnlinePstnUsage | ConvertTo-Json | Out-File -FilePath PSTNUsages.txt -Force -Encoding utf8)
$null = (Get-CsTeamsTranslationRule | ConvertTo-Json | Out-File -FilePath TranslationRules.txt -Force -Encoding utf8)
$null = (Get-CsOnlinePSTNGateway | ConvertTo-Json | Out-File -FilePath PSTNGateways.txt -Force -Encoding utf8)
}
Catch {
Write-Error -Message 'There was an error backing up the MS Teams Enterprise Voice configuration.'
Exit
}
$BackupFile = ('TeamsEVBackup_' + (Get-Date -Format yyyy-MM-dd) + '.zip')
$null = (Compress-Archive -Path $Filenames -DestinationPath $BackupFile -Force)
$null = (Remove-Item -Path $Filenames -Force -Confirm:$false)
Write-Host -Object ('Microsoft Teams Enterprise Voice configuration backed up to {0}' -f $BackupFile)