Skip to content

Commit 4f5d977

Browse files
lusassl-msftdpaulson45
authored andcommitted
Add update function to Public Folder scripts
1 parent 22f3c8a commit 4f5d977

34 files changed

Lines changed: 406 additions & 55 deletions

PublicFolders/Export-PublicFolderStatistics.ps1

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
Number of folder statistics results to buffer before writing to the output
2222
CSV. Must be 1 or greater. Defaults to 5.
2323
24+
.PARAMETER ScriptUpdateOnly
25+
Use this switch to only update the script to the latest released version without
26+
performing any other actions.
27+
28+
.PARAMETER SkipVersionCheck
29+
Use this switch to skip the automatic version check and script update.
30+
2431
.EXAMPLE
2532
.\Export-PublicFolderStatistics.ps1 -InputFile PublicFoldersToQuery.csv
2633
@@ -37,23 +44,33 @@
3744
- Progress is reported with `Write-Progress` and errors are logged to host.
3845
#>
3946

40-
[CmdletBinding()]
47+
[CmdletBinding(DefaultParameterSetName = "Default")]
4148
param (
4249

43-
[Parameter(Mandatory = $true)]
50+
[Parameter(Mandatory = $true, ParameterSetName = "Default")]
4451
[string]
4552
$InputFile,
4653

47-
[Parameter(Mandatory = $false)]
54+
[Parameter(Mandatory = $false, ParameterSetName = "Default")]
4855
[string]
4956
$OutputFile = "PublicFolderStatistics.csv",
5057

51-
[Parameter(Mandatory = $false)]
58+
[Parameter(Mandatory = $false, ParameterSetName = "Default")]
5259
[ValidateRange(1, [int]::MaxValue)]
5360
[int]
54-
$BatchSize = 5
61+
$BatchSize = 5,
62+
63+
[Parameter(Mandatory = $true, ParameterSetName = "ScriptUpdateOnly")]
64+
[switch]
65+
$ScriptUpdateOnly,
66+
67+
[Parameter(Mandatory = $false)]
68+
[switch]
69+
$SkipVersionCheck
5570
)
5671

72+
. $PSScriptRoot\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
73+
5774
# Import the list of public folders from the specified CSV input file. The
5875
# CSV is expected to contain a column named 'Identity' with each folder path.
5976
$publicFolders = Import-Csv -Path $InputFile

PublicFolders/MailPublicFolderSync/Import-MailPublicFolders.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#
1818
# Import-MailPublicFolders.ps1 -ToCloud
1919

20+
[CmdletBinding(DefaultParameterSetName = "Default")]
2021
param (
2122
[Parameter(Mandatory=$false)]
2223
[PSCredential] $Credential,
@@ -25,9 +26,17 @@ param (
2526
[Switch] $ToCloud,
2627

2728
[Parameter(Mandatory=$false)]
28-
[string] $ConnectionUri = "https://outlook.office365.com/powerShell-liveID"
29+
[string] $ConnectionUri = "https://outlook.office365.com/powerShell-liveID",
30+
31+
[Parameter(Mandatory=$true, ParameterSetName="ScriptUpdateOnly")]
32+
[switch] $ScriptUpdateOnly,
33+
34+
[Parameter(Mandatory=$false)]
35+
[switch] $SkipVersionCheck
2936
)
3037

38+
. $PSScriptRoot\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
39+
3140
# Create a tenant PSSession against Exchange Online with modern auth.
3241
function CreateTenantSession() {
3342
param (

PublicFolders/MailPublicFolderSync/Import-PublicFolderMailboxes.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,24 @@
1010
# Import-PublicFolderMailboxes.ps1 -ConnectionUri <cloud url>
1111
#
1212
# The above example imports public folder mailbox objects from cloud as mail enabled users to on-premise.
13+
[CmdletBinding(DefaultParameterSetName = "Default")]
1314
param (
1415
[Parameter(Mandatory = $false)]
1516
[PSCredential] $Credential,
1617

1718
[Parameter(Mandatory = $false)]
1819
[ValidateNotNull()]
19-
[string] $ConnectionUri = "https://outlook.office365.com/powerShell-liveID"
20+
[string] $ConnectionUri = "https://outlook.office365.com/powerShell-liveID",
21+
22+
[Parameter(Mandatory = $true, ParameterSetName = "ScriptUpdateOnly")]
23+
[switch] $ScriptUpdateOnly,
24+
25+
[Parameter(Mandatory = $false)]
26+
[switch] $SkipVersionCheck
2027
)
2128

29+
. $PSScriptRoot\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
30+
2231
#cspell:words EXOV2
2332

2433
## Create a tenant PSSession.

PublicFolders/MailPublicFolderSync/Sync-MailPublicFolders.ps1

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,46 @@
4444
#
4545
# This example shows how to use a different URI to connect to Exchange Online and sync mail-public folders from your local deployment.
4646
#
47+
# .PARAMETER ScriptUpdateOnly
48+
# Only updates the script to the latest released version without performing any other actions.
49+
#
50+
# .PARAMETER SkipVersionCheck
51+
# Skips the automatic version check and script update.
52+
#
53+
[CmdletBinding(DefaultParameterSetName = "Default")]
4754
param(
48-
[Parameter(Mandatory=$false)]
55+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
4956
[PSCredential] $Credential,
5057

51-
[Parameter(Mandatory=$true)]
58+
[Parameter(Mandatory=$true, ParameterSetName="Default")]
5259
[ValidateNotNullOrEmpty()]
5360
[string] $CsvSummaryFile,
5461

55-
[Parameter(Mandatory=$false)]
62+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
5663
[ValidateNotNullOrEmpty()]
5764
[string] $ConnectionUri = "https://outlook.office365.com/powerShell-liveID",
5865

59-
[Parameter(Mandatory=$false)]
66+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
6067
[bool] $Confirm = $true,
6168

62-
[Parameter(Mandatory=$false)]
69+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
6370
[switch] $FixInconsistencies = $false,
6471

65-
[Parameter(Mandatory=$false)]
72+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
6673
[switch] $Force = $false,
6774

75+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
76+
[switch] $WhatIf = $false,
77+
78+
[Parameter(Mandatory=$true, ParameterSetName="ScriptUpdateOnly")]
79+
[switch] $ScriptUpdateOnly,
80+
6881
[Parameter(Mandatory=$false)]
69-
[switch] $WhatIf = $false
82+
[switch] $SkipVersionCheck
7083
)
7184

85+
. $PSScriptRoot\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
86+
7287
# Writes a dated information message to console
7388
function WriteInfoMessage() {
7489
param ($message)

PublicFolders/MailPublicFolderSync/Sync-MailPublicFoldersCloudToOnprem.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,28 @@
1111
# Sync-MailPublicFoldersCloudToOnprem.ps1 -ConnectionUri <cloud url> -CsvSummaryFile <path for the summary file>
1212
#
1313
# The above example imports new mail public folders objects from Exchange Online as sync mail public folders to on-premise.
14+
[CmdletBinding(DefaultParameterSetName = "Default")]
1415
param (
15-
[Parameter(Mandatory=$false)]
16+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
1617
[PSCredential] $Credential,
1718

18-
[Parameter(Mandatory = $false)]
19+
[Parameter(Mandatory = $false, ParameterSetName="Default")]
1920
[ValidateNotNull()]
2021
[string] $ConnectionUri = "https://outlook.office365.com/powerShell-liveID",
2122

22-
[Parameter(Mandatory=$true)]
23+
[Parameter(Mandatory=$true, ParameterSetName="Default")]
2324
[ValidateNotNullOrEmpty()]
24-
[string] $CsvSummaryFile
25+
[string] $CsvSummaryFile,
26+
27+
[Parameter(Mandatory=$true, ParameterSetName="ScriptUpdateOnly")]
28+
[switch] $ScriptUpdateOnly,
29+
30+
[Parameter(Mandatory=$false)]
31+
[switch] $SkipVersionCheck
2532
)
2633

34+
. $PSScriptRoot\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
35+
2736
# cspell:words EXOV2 MEPF
2837

2938
# Writes a dated information message to console

PublicFolders/MailPublicFolderSync/Sync-ModernMailPublicFolders.ps1

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,46 @@
4444
#
4545
# This example shows how to use a different URI to connect to Exchange Online and sync modern mail-public folders from your local deployment.
4646
#
47+
# .PARAMETER ScriptUpdateOnly
48+
# Only updates the script to the latest released version without performing any other actions.
49+
#
50+
# .PARAMETER SkipVersionCheck
51+
# Skips the automatic version check and script update.
52+
#
53+
[CmdletBinding(DefaultParameterSetName = "Default")]
4754
param(
48-
[Parameter(Mandatory=$false)]
55+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
4956
[PSCredential] $Credential,
5057

51-
[Parameter(Mandatory=$true)]
58+
[Parameter(Mandatory=$true, ParameterSetName="Default")]
5259
[ValidateNotNullOrEmpty()]
5360
[string] $CsvSummaryFile,
5461

55-
[Parameter(Mandatory=$false)]
62+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
5663
[ValidateNotNullOrEmpty()]
5764
[string] $ConnectionUri = "https://outlook.office365.com/powerShell-liveID",
5865

59-
[Parameter(Mandatory=$false)]
66+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
6067
[bool] $Confirm = $true,
6168

62-
[Parameter(Mandatory=$false)]
69+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
6370
[switch] $FixInconsistencies = $false,
6471

65-
[Parameter(Mandatory=$false)]
72+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
6673
[switch] $Force = $false,
6774

75+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
76+
[switch] $WhatIf = $false,
77+
78+
[Parameter(Mandatory=$true, ParameterSetName="ScriptUpdateOnly")]
79+
[switch] $ScriptUpdateOnly,
80+
6881
[Parameter(Mandatory=$false)]
69-
[switch] $WhatIf = $false
82+
[switch] $SkipVersionCheck
7083
)
7184

85+
. $PSScriptRoot\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
86+
7287
# cSpell:words mepf, mepfs, EXOV2, MEPFDNs
7388

7489
# Writes a dated information message to console

PublicFolders/ManagePublicFolderPermissions.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Switch. When importing, skip folders that already have any permission entries ot
2929
.PARAMETER File
3030
Path to the CSV file to read (for import) or write (for export). If not specified during export, a timestamped file name is generated.
3131
32+
.PARAMETER ScriptUpdateOnly
33+
Switch. Only update the script to the latest released version without performing any other actions.
34+
35+
.PARAMETER SkipVersionCheck
36+
Switch. Skip the automatic version check and script update.
37+
3238
.EXAMPLE
3339
.
3440
.\ManagePublicFolderPermissions.ps1 -Export -Mailbox "PublicFolders" -File PFPerms.csv
@@ -91,10 +97,20 @@ param (
9197
[Parameter(Mandatory = $false, ParameterSetName = 'Import')]
9298
[ValidateRange(1, [int]::MaxValue)]
9399
[int]
94-
$BatchSize = 100
100+
$BatchSize = 100,
101+
102+
[Parameter(Mandatory = $true, ParameterSetName = 'ScriptUpdateOnly')]
103+
[switch]
104+
$ScriptUpdateOnly,
105+
106+
[Parameter(Mandatory = $false)]
107+
[switch]
108+
$SkipVersionCheck
95109
)
96110

97111
begin {
112+
. $PSScriptRoot\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
113+
98114
$foldersToProcess = [System.Collections.ArrayList]::new()
99115

100116
$ProgressPreference = 'Continue'

PublicFolders/Migration/ToExchangeOnline/Export-ModernPublicFolderStatistics.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,25 @@
55
# Export-ModernPublicFolderStatistics.ps1
66
# Generates a CSV file that contains the list of public folders and their individual sizes
77

8+
[CmdletBinding(DefaultParameterSetName = "Default")]
89
param(
910
# File to export to
1011
[Parameter(
1112
Mandatory=$true,
13+
ParameterSetName="Default",
1214
HelpMessage = "Full path of the output file to be generated. If only filename is specified, then the output file will be generated in the current directory.")]
1315
[ValidateNotNull()]
14-
[string] $ExportFile
16+
[string] $ExportFile,
17+
18+
[Parameter(Mandatory=$true, ParameterSetName="ScriptUpdateOnly")]
19+
[switch] $ScriptUpdateOnly,
20+
21+
[Parameter(Mandatory=$false)]
22+
[switch] $SkipVersionCheck
1523
)
1624

25+
. $PSScriptRoot\..\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
26+
1727
$ModernPublicFolderStatistics_LocalizedStrings = ConvertFrom-StringData @'
1828
ProcessingNonIpmSubtree = Enumerating folders under NON_IPM_SUBTREE...
1929
ProcessingNonIpmSubtreeComplete = Enumerating folders under NON_IPM_SUBTREE completed...{0} folders found.

PublicFolders/Migration/ToExchangeOnline/ModernPublicFolderToMailboxMapGenerator.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,47 @@
55
# ModernPublicFolderToMailboxMapGenerator.ps1
66
# Generates a CSV file that contains the mapping of modern public folder branch to mailbox
77

8+
[CmdletBinding(DefaultParameterSetName = "Default")]
89
param(
910
# Mailbox size
1011
[Parameter(
1112
Mandatory=$true,
13+
ParameterSetName="Default",
1214
HelpMessage = "Size (in Bytes) of any one of the Public folder mailboxes in destination. (E.g. For 1GB enter 1 followed by nine 0's)")]
1315
[long] $MailboxSize,
1416

1517
# Mailbox Recoverable item size
1618
[Parameter(
1719
Mandatory=$true,
20+
ParameterSetName="Default",
1821
HelpMessage = "Recoverable Item Size (in Bytes) of any one of the Public folder mailboxes in destination. (E.g. For 1GB enter 1 followed by nine 0's)")]
1922
[long] $MailboxRecoverableItemSize,
2023

2124
# File to import from
2225
[Parameter(
2326
Mandatory=$true,
27+
ParameterSetName="Default",
2428
HelpMessage = "This is the path to a CSV formatted file that contains the folder names and their sizes.")]
2529
[ValidateNotNull()]
2630
[string] $ImportFile,
2731

2832
# File to export to
2933
[Parameter(
3034
Mandatory=$true,
35+
ParameterSetName="Default",
3136
HelpMessage = "Full path of the output file to be generated. If only filename is specified, then the output file will be generated in the current directory.")]
3237
[ValidateNotNull()]
33-
[string] $ExportFile
38+
[string] $ExportFile,
39+
40+
[Parameter(Mandatory=$true, ParameterSetName="ScriptUpdateOnly")]
41+
[switch] $ScriptUpdateOnly,
42+
43+
[Parameter(Mandatory=$false)]
44+
[switch] $SkipVersionCheck
3445
)
3546

47+
. $PSScriptRoot\..\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
48+
3649
################ START OF DEFAULTS ################
3750

3851
$script:Exchange15MajorVersion = 15

PublicFolders/Migration/ToExchangeOnline/SetMailPublicFolderExternalAddress.ps1

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,33 @@
1212
# The Confirm switch causes the script to pause processing and requires you to acknowledge what the script will do before processing continues. You don't have to specify
1313
# a value with the Confirm switch.
1414
#
15+
# .PARAMETER ScriptUpdateOnly
16+
# Only updates the script to the latest released version without performing any other actions.
17+
#
18+
# .PARAMETER SkipVersionCheck
19+
# Skips the automatic version check and script update.
20+
#
1521
# .EXAMPLE
1622
# .\SetMailPublicFolderExternalAddress.ps1 -ExecutionSummaryFile:summary.csv
1723

24+
[CmdletBinding(DefaultParameterSetName = "Default")]
1825
param(
19-
[Parameter(Mandatory=$true)]
26+
[Parameter(Mandatory=$true, ParameterSetName="Default")]
2027
[ValidateNotNullOrEmpty()]
2128
[string] $ExecutionSummaryFile,
2229

30+
[Parameter(Mandatory=$false, ParameterSetName="Default")]
31+
[bool] $Confirm = $true,
32+
33+
[Parameter(Mandatory=$true, ParameterSetName="ScriptUpdateOnly")]
34+
[switch] $ScriptUpdateOnly,
35+
2336
[Parameter(Mandatory=$false)]
24-
[bool] $Confirm = $true
37+
[switch] $SkipVersionCheck
2538
)
2639

40+
. $PSScriptRoot\..\..\..\Shared\ScriptUpdateFunctions\GenericScriptUpdate.ps1
41+
2742
# cSpell:words mepf, mepfs
2843

2944
$LocalizedStrings = ConvertFrom-StringData @'

0 commit comments

Comments
 (0)