<#
#################################################################################
## Author: BRIAN HUNTER
## Date: 8/10/2020
## Email: brian@sutechy.com
#################################################################################
#>
$var = & cmd.exe /c C:\Windows\System32\cmdkey.exe /list | Select-String "Target"
$x = $var -Split ([Environment]::NewLine)
$y = $x -Split "Target: "
$z = $y -Split "`r"
$z = $z -replace " *",""
Write-Host "CRED TO DELETE>> $z"
foreach($one in $z) {
if($one) {
Write-Host "TEST1>> $one"
& cmd.exe /c C:\Windows\System32\cmdkey.exe /delete:"$one"
if($?) { Write-Host "TEST2>> Delete Successful" }
else { Write-Host "TEST3>> Delete Failed" }
} # else { Write-Host "ALERT>> I AM NULL" }
}
<#
# This one opens up a gui and you can delete all.
rundll32.exe keymgr.dll, KRShowKeyMgr
# This one does not delete all, Target: (with spaces )
cmdkey /list | ForEach-Object{if($_ -like "*Target:*"){cmdkey /del:($_ -replace " ","" -replace "Target:","")}}
#>