I was looking for this information a week ago and it seems to be missing on the web so now that i have figured it out, it time to share.
This script is designed to check the computer’s credential manager for certain credentials you specify in the filter and delete them, as simple as that.
This is useful for mass deployment where script can be pushed via Group Policy Objects (GPO) or any other deployment tools, not really needed for small environment. Due to numerous different deployment tools i have created the script in two format Batch (CMD) and Powershell (PS1).
Before running or apply the script to a group of computers please make sure they meet the requirement to have the CMDKey command.
https://technet.microsoft.com/en-us/library/cc754243.aspx
If you can’t copy and paste script here ClearCredMan.zip
Enjoy!!!!
#Clearing Credential Manager #Hannel Hazeley #hhazeley@outlook.com #Version 2.0 #Set filters to query cerdential manager for $filters = "TestScript*" #Extract information from Credential Manager and filter only Target. Foreach ($filter in $filters) { $keys = cmdkey /list:($filter) | Findstr "Target" $keys = ($keys -replace " ","" -replace "Target:","") #Delete each target Foreach ($key in $keys) { Write-Host "Removing credentials for target $key" Write-host cmdkey /del:($key) #for script to actually work remove 'Write-host' } }
@echo off
setlocal
set Filter=TestScript
for /f "tokens=1*" %%a in ('cmdkey.exe /list ^| find /i "%Filter%"') do (
echo Removing credentials for target '%%~b'
:: Remove 'echo' from line below for script to work
echo cmdkey.exe /delete:"%%~b"
)