Functions/LDAPDirectories/Remove-PASDirectory.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
function Remove-PASDirectory {
    <#
.SYNOPSIS
Removes an LDAP directory configured in the Vault
 
.DESCRIPTION
Removes an LDAP directory configuration from the vault.
Membership of the Vault Admins group required.
 
.PARAMETER id
The ID or Name of the directory to return information on.
 
.EXAMPLE
Remove-PASDirectory -id LDAPDirectory
 
Removes LDAP directory configured in the Vault
 
.INPUTS
WebSession & BaseURI can be piped to the function by propertyname
 
.OUTPUTS
LDAP Directory Details
 
.LINK
https://pspas.pspete.dev/commands/Remove-PASDirectory
#>

    [CmdletBinding(SupportsShouldProcess = $true)]
    param(
        [parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true
        )]
        [Alias("DomainName")]
        [string]$id

    )

    BEGIN {
        $MinimumVersion = [System.Version]"10.7"
    }#begin

    PROCESS {

        Assert-VersionRequirement -ExternalVersion $Script:ExternalVersion -RequiredVersion $MinimumVersion

        #Create URL for request
        $URI = "$Script:BaseURI/api/Configuration/LDAP/Directories/$id"

        if ($PSCmdlet.ShouldProcess($id, "Delete Directory")) {

            #send request to web service
            Invoke-PASRestMethod -Uri $URI -Method DELETE -WebSession $Script:WebSession

        }

    }#process

    END { }#end
}