Public/PersistentStore/Reset-R1StoreIndex.ps1

# .ExternalHelp psRadiantOne-help.xml
function Reset-R1StoreIndex {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
    [OutputType('psRadiantOne.LaunchedTask')]
    param(
        [parameter(
            Mandatory = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [ValidateNotNullOrEmpty()]
        [string]$dn
    )

    Begin {

        Assert-R1Session -RequireToken

    }#begin

    Process {

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

        if ($PSCmdlet.ShouldProcess($dn, 'Rebuild Directory Store Index')) {

            $Result = Invoke-R1RestMethod -Uri $URI -Method POST

            if ($null -ne $Result) {

                $Result | Add-CustomType -Type psRadiantOne.LaunchedTask

            }

        }

    }#process

    End { }#end

}