Public/PersistentStore/Export-R1StoreBackup.ps1

# .ExternalHelp psRadiantOne-help.xml
function Export-R1StoreBackup {
    [CmdletBinding()]
    [OutputType('System.IO.FileInfo')]
    param(
        [parameter(
            Mandatory = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateNotNullOrEmpty()]
        [string]$dn,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $false
        )]
        [ValidateNotNullOrEmpty()]
        [string]$Path
    )

    Begin {

        Assert-R1Session -RequireToken

    }#begin

    Process {

        $URI = Resolve-R1ServiceUrl -Service Namespace -Path "naming_contexts/$($dn | Get-EscapedString)/store/backup/download"

        $Download = @{
            Uri         = $URI
            Method      = 'GET'
            DefaultName = "$dn.zip"
        }

        if ($PSBoundParameters.ContainsKey('Path')) {

            $Download['Path'] = $Path

        }

        Save-R1Download @Download

    }#process

    End { }#end

}