1

I am looking for a way to remove linked mail accounts from a local Windows user via a script from the command line, or another way I can reliably schedule.

I'm not talking about a Microsoft account, I'm taking about the other mail/work accounts you can link to a Local Windows User

Email settings

I can remove them with ease from the graphical interface, however I'm looking for a way to schedule the operation as I have a number of laptops that are used for classroom courses by new users on a daily basis, and it's not always feasible/doable to reset them to a specific recovery point. I'm trying to protect users who may accidentally save their personal accounts on the machine.

My plan was to schedule a cleanup with an agent installed on the machines, I don't know however how to remove these accounts (Best option for me would be to indiscriminately delete them all). If there are other options feel free to share them, tho they might not be applicable to my use case.

I'm on windows 10

Thanks in advance

4
  • I wish I had time to dig into this for you. I vaguely recall when a company I support first when to M365, there was a correlated registry setting with this account data within it. I ended up having to purge those and reboot I think. Here's a question somewhat related I think that I asked about a specific Outlook M365 issue, but it may be the things I harry's answer there which I gave him the bounty, if you have time to read and test, that may be helpful perhaps: superuser.com/questions/1680414/…. My wires could be crossed! Commented May 24, 2023 at 21:12
  • 1
    Thank you, I did some digging of my own in the meantime and I found a way to locate the registry keys that are generated when an account is linked, they are under HKEY_CURRENT_USER\Software\Microsoft\IdentityCRL\UserExtendedProperties. Unless there's a better way I guess I'll just make a small program that emails me if one is found so I can manually remove it without working directly with the registry Commented May 25, 2023 at 6:57
  • I would also suggest you add your solution to a self-answer on this question post as an actual answer and not an edit to the question or just in the comment. This may provide others a better starting point should they need something like this which you asked should they come here looking for something. Keep asking and keep answering Mattia, give back as much as possible as you have time! I'm glad to hear you found that and I look forward to reading over any answer you provide to your question since you found the precise location in the registry. Commented May 26, 2023 at 16:24
  • It occorred to me to do that, but it seemed to me that my solution would not be an answer to my problem, as it manages only to detect the situation rather than act on it. If a way to properly do this exists and someone knows it I believe there should be room to properly answer. I guess I should add an answer but I wouldn't consider it a solution Commented May 29, 2023 at 11:28

1 Answer 1

0

I did some digging of my own in the meantime and I found a way to locate the registry keys that are generated when an account is linked, they are under HKEY_CURRENT_USER\Software\Microsoft\IdentityCRL\UserExtendedProperties.

This only applies to "account used by other apps". So maybe there's a better way to do this, but I guess in the meantime I'll just make a small program that emails me if one is found so I can manually remove it without working directly with the registry.

If someone knows a better way to check those accounts, or clues on possible ways to do so please feel free to share them

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .