-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathremove-onPremGroup.ps1
74 lines (51 loc) · 2.17 KB
/
remove-onPremGroup.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
<#
.SYNOPSIS
This function disables all open powershell sessions.
.DESCRIPTION
This function disables all open powershell sessions.
.PARAMETER globalCatalogServer
The global catalog server to run operations on.
.PARAMETER originalDLConfiguration
The original DL configuration
.PARAMETER adCredential
The active directory credential
.OUTPUTS
No return.
.EXAMPLE
disable-allPowerShellSessions -globalCatalogServer $GC -originalDLConfiguration $config -adCredential $CRED
#>
Function remove-onPremGroup
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
[string]$globalCatalogServer,
[Parameter(Mandatory = $true)]
$originalDLConfiguration,
[Parameter(Mandatory = $true)]
$adCredential,
[Parameter(Mandatory = $false)]
[ValidateSet("Basic","Negotiate")]
$activeDirectoryAuthenticationMethod="Negotiate"
)
#Output all parameters bound or unbound and their associated values.
write-functionParameters -keyArray $MyInvocation.MyCommand.Parameters.Keys -parameterArray $PSBoundParameters -variableArray (Get-Variable -Scope Local -ErrorAction Ignore)
[string]$isTestError="No"
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN remove-onPremGroup"
Out-LogFile -string "********************************************************************************"
out-logFile -string "Remove on premises distribution group."
try
{
remove-adobject -identity $originalDLConfiguration.distinguishedName -server $globalCatalogServer -credential $adCredential -authType $activeDirectoryAuthenticationMethod -confirm:$FALSE -errorAction STOP
}
catch
{
out-logfile -string $_
$isTestError="Yes"
}
Out-LogFile -string "END remove-onPremGroup"
Out-LogFile -string "********************************************************************************"
return $isTestError
}