Public/DirectoryBrowser/Export-R1DirectoryLdif.ps1

# .ExternalHelp psRadiantOne-help.xml
function Export-R1DirectoryLdif {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
    [OutputType([void])]
    param(
        [parameter(
            Mandatory = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateNotNullOrEmpty()]
        [string]$sourceDn,

        [parameter(
            Mandatory = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateSet('BASE', 'ONE', 'SUB')]
        [string]$scope,

        [parameter(
            Mandatory = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidatePattern('^[\w,\s-]+\.(ldif|ldifz|LDIF|LDIFZ)$')]
        [string]$fileName,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [string]$targetDn,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateRange(0, 100000)]
        [int]$maxEntries,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$isExportForReplication
    )

    Begin {

        Assert-R1Session -RequireToken

    }#begin

    Process {

        $URI = Resolve-R1ServiceUrl -Service Browser -Path 'directory_browser/ldif/export'

        $Body = $PSBoundParameters | Get-Parameter | ConvertTo-R1JsonBody

        if ($PSCmdlet.ShouldProcess($sourceDn, "Export LDIF to $fileName")) {

            $null = Invoke-R1RestMethod -Uri $URI -Method POST -Body $Body

        }

    }#process

    End { }#end

}