6

cmdkey seems to be unable to delete credentials by target name when said name includes a space and a dash -

I have a credential Test Credential - Iteration1 which I want to delete, but when I try

cmdkey /del:Test Credential - Iteration1

I get The command line parameters are incorrect. since I guess it's taking the dash as a new parameter.

So far I've tried quotes, double quotes, 2 double quotes, escaping the dash with ^, enclosing with {} and none of those work:

cmdkey /del:Test Credential - Iteration1
cmdkey "/del:Test Credential - Iteration1"
cmdkey /del:"Test Credential - Iteration1"
cmdkey /del:{Test Credential - Iteration1}
cmdkey {/del:"Test Credential - Iteration1}
cmdkey /del:{LegacyGeneric:target=Test Credential - Iteration1}

How can I delete with cmdkey the credential Test Credential - Iteration1

EDIT: I validated that the command works for names without spaces. I created TestCredential-Iteration1 and the following command deletes it successfuly

cmdkey /del:TestCredential-Iteration1
life makes
  • 71
  • 1
  • 4
  • 1
    I thought it was `/delete` not `/del`, i.e `cmdkey /delete:FullyQualifiedDomainNameOfServer`. – Compo Jul 27 '18 at 21:14
  • They are equivalent. And I tried with both all the alternatives. The documentation only specifies /delete though, but that doesn't work either. – life makes Jul 27 '18 at 21:17
  • What displays when you use the `/LIST` option? – Squashman Jul 27 '18 at 21:40
  • `Target: LegacyGeneric:target=Test Credential - Iteration1 Type: Generic User: 9a004233-bf81-4741-b640-74ed99553b5f Local machine persistence` – life makes Jul 27 '18 at 21:55
  • You put double quotes around the parameter, which you have not done above. `cmdkey /del:"TestCredential-Iteration1"` – CatCat Jul 27 '18 at 22:03
  • I did try it, I listed this as one of the examples of things I tried `cmdkey /del:"Test Credential - Iteration1"` – life makes Jul 27 '18 at 23:59

1 Answers1

3

I had a similar issue. First I found this code:

cmdkey /list | ForEach-Object{if($_ -like "*Target:*"){cmdkey /del:($_ -replace " ","" -replace "Target:","")}}

https://gist.github.com/janikvonrotz/7819990, which allowed me to delete all credentials except the one with spaces. Then I ran this:

rundll32.exe keymgr.dll, KRShowKeyMgr 

from here: https://forflukesake.co.za/wp/clear-credential-manager-fast/ and that opened up the gui and allowed me to remove it.

Dharman
  • 30,962
  • 25
  • 85
  • 135
jsahlsa
  • 31
  • 5