Keychain Scripting Help

Hey all,

I’m trying to create a script that will delete all instances of a certain key. I have a sample script below:

tell application “Keychain Scripting”
tell current keychain
unlock
repeat with this_key in (get keys)
if ((get name of this_key) = “NameOfKey”) then
delete this_key
end if
end repeat
end tell
end tell

Problem is, it keeps giving me an error message. Normally, I’ll have 3-4 keys for the above. This is usually passwords for mounted servers. I want to get rid of the keys so it will ask me for my password again.

Any help would be appreciated.

Cheers.
Michael