Strange caching(?) problem

Strange caching(?) problem

avatar

Hi!

I ran in some strange problems. When testing scrips I often create and delete folder/entries with the same name. Before creating a folder/entrie I test if this forlder/entrie exists:

function Test-EntryExists {
param (
        [Parameter(Mandatory)]
        [string] $Folder
        )
    $retval = $true
    $entryName = $Folder.Split("\")[-1]
    try{
        $session = Get-RDMSession -Name $entryName -Group $Folder -ErrorAction Stop
        if($session.count -eq 0){
            $retval = $false
        }
    }
    catch{$retval = $false}
    return $retval
}

Sometimes I get a false back although the folder exists. Creating this folder creates an error "Folder already exists".
Closing the powershell session and using a new one to test the existing of the folder returns the correct value true.
So it seems to be an kind of caching problem.

Parallel to the powershell session I have a RDM desktop session open. I was not able to figure out a way to reproduce this behavior.

Is there a method to refresh the data in the powershell session?

Using Powershell 7.4, Devolutions.Powershell module 2023.2.0.10 and RDM 2023.2.32.0
I can not update RDM or module.


CU,
Timo

All Comments (1)

avatar

Hello,

You can use the Update-RDMEntries cmdlet to update the cache before testing if an entry exists.

Let us know if that helps.

Best regards,

Érica Poirier