-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisable-OriginalDL.ps1
89 lines (59 loc) · 2.68 KB
/
Disable-OriginalDL.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
85
86
87
88
89
<#
.SYNOPSIS
This function disabled the on premies distribution list - removing it from azure ad and exchange online.
.DESCRIPTION
This function disabled the on premies distribution list - removing it from azure ad and exchange online.
.PARAMETER parameterSet
These are the parameters that will be manually cleared from the object in AD mode.
.PARAMETER DN
The DN of the contact to remove.
.PARAMETER GlobalCatalog
The global catalog server the operation should be performed on.
.PARAMETER UseExchange
If set to true disablement will occur using the exchange on premises powershell commands.
.OUTPUTS
No return.
.EXAMPLE
Get-ADObjectConfiguration -powershellsessionname NAME -contactSMTPAddress Address
#>
Function Disable-Originalcontact
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
$originalContactConfiguration,
[Parameter(Mandatory = $true)]
[string]$globalCatalogServer,
[Parameter(Mandatory = $false)]
[array]$parameterSet="None",
[Parameter(Mandatory = $true)]
$adCredential
)
#Declare function variables.
$functioncontactConfiguration=$NULL #Holds the return information for the contact query.
#Start function processing.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN Disable-originalContactConfiguration"
Out-LogFile -string "********************************************************************************"
#Log the parameters and variables for the function.
Out-LogFile -string ("originalContactConfiguration = "+$originalContactConfiguration)
Out-LogFile -string ("GlobalCatalogServer = "+$globalCatalogServer)
out-logfile -string ("DN of object to modify / disable "+$originalContactConfiguration.distinguishedName)
OUt-LogFile -string ("Parameter Set:")
foreach ($parameterIncluded in $parameterSet)
{
Out-Logfile -string $parameterIncluded
}
#Get the contact using LDAP / AD providers.
try
{
set-adObject -identity $originalContactConfiguration.distinguishedName -server $globalCatalogServer -clear $parameterSet -credential $adCredential
}
catch
{
Out-LogFile -string $_ -isError:$TRUE
}
Out-LogFile -string "END Disable-originalContactConfiguration"
Out-LogFile -string "********************************************************************************"
}