Public/PersistentStore/Restore-R1Store.ps1

# .ExternalHelp psRadiantOne-help.xml
function Restore-R1Store {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
    [OutputType([void])]
    param(
        [parameter(
            Mandatory = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateNotNullOrEmpty()]
        [string]$dn,

        [parameter(
            Mandatory = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateLength(1, 1000)]
        [Alias('id')]
        [string]$backupId
    )

    Begin {

        Assert-R1Session -RequireToken

    }#begin

    Process {

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

        $Body = @{ backupId = $backupId } | ConvertTo-R1JsonBody

        if ($PSCmdlet.ShouldProcess($dn, "Restore Directory Store from Backup '$backupId'")) {

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

        }

    }#process

    End { }#end

}