Deleting entries from vaults

Deleting entries from vaults

avatar

I have ~30 vaults in a demo environment that I need to wipe. I don't want to delete the vault because I have the permissions perfect and it was a pain to do for all of the 30 vaults. However, manually deleting everything from each vault is very time consuming, taking about 5 minutes to delete 300 entries. Some vaults have well over 2000 entries, so waiting is not feasible.

I am looking for a quicker solution. Support suggested posting here to see if this was possible via PowerShell.

All Comments (9)

avatar

Hello John,

Do you want to delete all the entries, including folders, in the vaults? Or you want to keeps the folders since the permissions were also applied to them?

Once we have the information, we can provide you with a script.

Best regards,

Richard Boisvert

avatar

Folders included, I am looking for empty vaults.

I was under the impression that folders had inherited vault permissions. I never have to apply permissions to folders when I imported before.

avatar

Hello John,

You can use this script. As always, we recommend you do a backup of your DB beforehand.

#load the RDM module
if ( ! (Get-module RemoteDesktopManager.PowerShellModule )) {
    Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1"
}
# ** The name of the data source needs to be modified **
Get-RDMDataSource -Name "name_of_datasource" | Set-RDMCurrentDataSource
Update-RDMUI

#loop into all vaults and delete all entries
$vaults = Get-RDMVault
foreach ($vault in $vaults){
    Set-RDMCurrentRepository $vault
    Update-RDMUI
    Get-RDMSession | Remove-RDMSession -Force
    }
Update-RDMUI

Best regards,

Richard Boisvert

avatar

@Richard Boisvert
Tried your PS script on Remote Desktop Manager Enterprise 64-Bit Version 2020.3.28.0 and it didn't work. Debugging the lines, I've found $vaults is empty, therefore it's not deleting anything.

I've modified like this and it successfully deleted entries from my local RDM database. I'm using the default local database here (without a central server DBMS).

I still need help because it left 55 entries in my local database instead of deleting everything from it. I noticed all 55 entries were links to other entries. How can I auto-accept deleting links and everything pointing to those entries so I really get everything deleted?

Thanks for your answer.

Here's my script:
$DS_NAME="vm-rsat-rdm"
if (!(Get-module RemoteDesktopManager.PowerShellModule)) {
Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1"
}
Get-RDMDataSource -Name $DS_NAME | Set-RDMCurrentDataSource
Update-RDMUI
Get-RDMSession | Remove-RDMSession -Force
Update-RDMUI

avatar

Hello,

You are correct, if you are using a local database, you will not have multiple vaults, so that line would not return anything. The previous scenario was used to delete entries from a vault without removing permissions, but it does not apply with a local data source, since you cannot set permissions.

In your case, you could simply create a new data source and remove the old one. It would need to be done from the UI (File > Data Sources) unfortunately since the PowerShell command cannot create the .db file.

If you prefer to it from PowerShell, could you specify what type of entries is causing the issue, sub-connections for example? I did some tests on my end and was not able to remain with anything after using

Get-RDMSession | Remove-RDMSession -Force
Update-RDMUI


Best regards,

Richard Boisvert

avatar

@Richard Boisvert

Here's a video how to reproduce the bug: https://www.youtube.com/watch?v=AvClcGr64O0

avatar

Hello,

I now see you meant with a shortcut. In that case, you would need to run it twice to get rid of everything. When you delete a shortcut, the default is to delete only this entry, leaving the other ones in place, which is what happens when doing it from PowerShell.

forum image
The workaround would be to do the following:

if (!(Get-module RemoteDesktopManager.PowerShellModule)) {
    Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1"
}

Get-RDMSession | Remove-RDMSession -Force
Update-RDMUI
Get-RDMSession | Remove-RDMSession -Force
Update-RDMUI

Best regards,

Richard Boisvert

avatar

@Richard Boisvert

Thanks for the workaround. It makes more entries being deleted, but I still have 5 entries - also shortcuts - left which aren't deleted no matter how often I call the PS script.

I'd love to see this fixed as I refresh a database with MFA set-up manually from time over time and don't like to go through the whole new rdm DB creation process every time including editing the secret keys in phone authenticator apps.

What about Devolutions adding a --delete-shortcuts option for the Remove-RDMSession cmdlet?

avatar

Hello,

The engineering team is considering adding a "Delete All" parameter. In the meantime, you can use this workaround:

$session = Get-RDMSession
Foreach ($s in $session)
{
 $s.Group = ''
}
Set-RDMSession -Session $session
Update-RDMUI
Get-RDMSession | Remove-RDMSession -Force
Update-RDMUI


Best regards,

Richard Boisvert