off-boarding remote user with cache domain credentials

This would apply to users who have a domain joined machine but work off site.
Comments
-
IN theory this should be pretty straightforward. Cached Credentials are located in the registry under a key with the System user has rights to... according to the article here: it's as simple as clearing out the binary values to "0".
https://www.mysysadmintips.com/windows/clients/6-clear-cached-credentials
Then doing the logout. I haven't tested but it should be something like this:
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$1", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$2", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$3", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$4", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$5", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$6", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$7", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$8", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$9", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
setRegistryValue("HKEY_LOCAL_MACHINE\Security\Cache\NL$10", "0","REG_BINARY", "All Operating Systems", "Halt on Fail")
LogoffCurrentUser(" ", "All Operating Systems", "Halt on Fail")0 -
use 00 for the value instead of 0 and use a reboot instead of logoffcurrentuser and it'll work no problem.
0