Disconnect Accounts Via Script/Registry/Directory Clearing

Nathaniel Alves 1 Reputation point
2021-03-08T18:53:03.853+00:00

Hello,

I am running into an issue where users on kiosk devices are connecting their work/school accounts under emails and accounts. We have a GPO set to block the accounts and that works when they try to login under "Access work or school" but if they go to "Email & Accounts" and select "Add a work or school account" it allows them to connect it. We have a SSO badge tap software that I am using to invoke a script on badge out. I found that clearing all files and sub-folders from c:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy and then rebooting clears and disconnects the account at the next time the device auto-logs in.

However, I am looking for a way to disconnect the accounts in the moments via script whether it be registry changes or other directories I am missing.

Thoughts?

Nate

Windows for business | Windows Client for IT Pros | Devices and deployment | Configure application groups
Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-03-09T09:38:00.693+00:00

    Hi,

    To delete files you can use the Remove-Item cmdlet

    $path = "c:\Users\$env:username\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy"  
    Get-ChildItem -Path $path | Remove-Item -Recurse  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.