PSKeePass / PoShKeePass

PowerShell module for KeePass

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove-KeePassGroup doesn't remove the group.

yllekz opened this issue · comments

EDIT: I meant to say "Remove-KeePassGroup" in the title

Remove-KeePassGroup doesn't seem to work correctly. It only creates the group entry (without sub-entries) in the recycle bin if I don't specify -norecycle. If i specify -norecycle, then the command does nothing.

It won't delete the group, nor delete the entries in the group.

Sample code:

$entrylivesin = read-host 'enter the path of the group to delete (example: TestDB/General/TestGroup1)'
$DBProfileName = 'testdb'
$GroupPSObject = get-keepassgroup -DatabaseProfileName $DBProfileName -KeePassGroupPath $Entrylivesin | convertto-KPPsObject
Remove-KeePassGroup -databaseprofilename $DBProfileName -keepassgroup $GroupPSObject -force -NoRecycle

@yllekz I took a quick glance at this and before we investigate this further I think the issue is that you are piping to the ConvertTo-KPPSObject.

I would recommend trying the remove again without the conversion.

The conversion also adds unnecessary over head since you are not looking at any of the properties that are being converted to plain text.

Example without the conversion:

$entrylivesin = read-host 'enter the path of the group to delete (example: TestDB/General/TestGroup1)'
$DBProfileName = 'testdb'
$GroupPSObject = get-keepassgroup -DatabaseProfileName $DBProfileName -KeePassGroupPath $Entrylivesin 
Remove-KeePassGroup -databaseprofilename $DBProfileName -keepassgroup $GroupPSObject -force -NoRecycle

I would imagine in the future the ability to remove a converted object should be supported.

Let me know if this works and if not I will look into this further.

John

Thanks for the reply jkdba, however after running the modified code you provided above, I still get the same result.

Neither the group, nor the entries inside it are deleted in the kdbx. I tried without the -force switch to see the prompts (for a sanity check) and while yes it prompts to remove it, it doesn't appear to go through with it.

@yllekz, ok thanks for trying, what version is your keepass database?

I am running KeePass 2.38, I'm not sure what version the database version is aside from the "new format" aka the 2.x format. Let me know if you need more info.

@yllekz ah makes sense ok I am working on getting the module to the latest version, but as of now its using version 2.34, I suspect that there will be some version compatibility issues.

You can check out this untested solution provided here: #130 although there are likely code changes that will prevent this from being the solution.

Getting to the latest version is top priority at the moment.