-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-Office365Contact.ps1
84 lines (56 loc) · 2.57 KB
/
new-Office365Contact.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<#
.SYNOPSIS
This function creates the new distribution contact in office 365.
.DESCRIPTION
This function creates the new distribution contact in office 365.
.PARAMETER originalContactConfiguration
The original configuration of the contact on premises.
.PARAMETER contactTypeOverride
Submits the contact type override of specified by the administrator at run time.
.OUTPUTS
None
.EXAMPLE
new-Office365contact -contactTypeOverride "Security" -originalContactConfiguration adConfigVariable.
#>
Function new-office365contact
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
$originalContactConfiguration,
[Parameter(Mandatory = $true)]
$office365contactConfiguration
)
#Declare function variables.
[string]$functioncontactType=$NULL #Holds the return information for the contact query.
[string]$functionMailNickName = ""
[string]$functionName = ((Get-Date -Format FileDateTime)+(Get-Random)).tostring()
$functioncontact = $NULL
#Start function processing.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN New-Office365contact"
Out-LogFile -string "********************************************************************************"
#Log the parameters and variables for the function.
Out-LogFile -string ("originalContactConfiguration = ")
out-logfile -string $originalContactConfiguration
out-logfile -string ("Office365contactConfiguration = ")
out-logfile -string $office365contactConfiguration
#Calculate the contact type to be utilized.
#Three values - either NULL,Security,or Distribution.
out-logfile -string ("Random contact name: "+$functionName)
#Create the distribution contact in office 365.
try
{
out-logfile -string "Creating the distribution contact in Office 365."
$functioncontact = new-o365mailcontact -externalEmailAddress $office365contactConfiguration.externalEmailAddress -name $functionName -errorAction STOP
out-logfile -string $functioncontact
}
catch
{
Out-LogFile -string $_ -isError:$TRUE
}
Out-LogFile -string "END New-Office365contact"
Out-LogFile -string "********************************************************************************"
return $functioncontact
}