Functions/LDAPDirectories/Remove-PASDirectoryMapping.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
function Remove-PASDirectoryMapping {
    <#
.SYNOPSIS
Removes a configured directory mapping from the Vault

.DESCRIPTION
Removes a directory mapping configuration from the vault.
Membership of the Vault Admins group required.

.PARAMETER DirectoryName
The Name of the directory containing the mapping.

.PARAMETER MappingID
The id of the directory mapping to delete.

.EXAMPLE
Remove-PASDirectoryMapping -DirectoryName SomeDir -MappingID 66

Removes the directory mapping with id 66 for the SomeDir directory

.INPUTS
WebSession & BaseURI can be piped to the function by propertyname

.OUTPUTS
LDAP Directory Details

.LINK
https://pspas.pspete.dev/commands/Remove-PASDirectoryMapping
#>

    [CmdletBinding(SupportsShouldProcess = $true)]
    param(
        [parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true
        )]
        [string]$DirectoryName,

        [parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true
        )]
        [string]$MappingID
    )

    BEGIN {
        Assert-VersionRequirement -RequiredVersion 11.1
    }#begin

    PROCESS {

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

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

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

        }

    }#process

    END { }#end
}