-
Notifications
You must be signed in to change notification settings - Fork 0
/
Export-CalCon-Exchange.ps1
65 lines (39 loc) · 1.06 KB
/
Export-CalCon-Exchange.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
56
57
58
59
60
61
62
63
64
<#PSScriptInfo
.VERSION 0.2
.GUID 6de48057-fd1d-4c58-9039-205de13b3f02
.AUTHOR wayne@ramblinggeek.co.uk
.COMPANYNAME
.COPYRIGHT
.TAGS
.LICENSEURI
.PROJECTURI https://github.com/RamblingGeekUK/Export-CalCon-Exchange
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
<#
.DESCRIPTION
A script to loop through Exchange Mailboxes and export Contacts and Calendars
#>
param([string]$SMTPDomain="", [string]$FilePath="", [int]$Max=50)
#
# Requires User is a member of the ImportExport Role
# New-ManagementRoleAssignment –Role "Mailbox Import Export" –User "user name"
$limit = 0 # reset limit on first run
$mailboxes = Get-Mailbox | Where-Object {$_.EmailAddresses -like "*"+$SMTPDomain} | Select-Object Alias
foreach ($mailbox in $mailboxes)
{
if ($limit -ne $Max)
{
$Filename = $FilePath + "\" + $mailbox.Alias + ".pst"
New-MailboxExportRequest -Mailbox $mailbox.alias -IncludeFolders "#Calendar#","#Contacts#" -FilePath $Filename
}
else
{
break
}
# increase count
$limit++
}