Category filter

Script to enable or disable Microsoft accounts on Windows 10

Users sign in to their Windows devices using either a Local account or a Microsoft Account. Though these accounts are often created for a user by the administrators, they may choose to defer logins using these accounts. Unlike a Local account, the Microsoft Account needs to be responsibly handled because it lets users sync data and settings, making it easier to access this information anytime and vulnerable to hacking. The following PowerShell scripts help you disable the Microsoft accounts existing on Windows 10 devices. Then, with the help of Execute Custom Script action, you can quickly execute them on the devices.

Disclaimer:


The Sample Scripts provided below are adapted from third-party Open-Source sites.

Disable Microsoft Accounts on Windows

If you choose to disable all the Microsoft Accounts existing on the devices, the following script helps.

Alternatively, you can get all the Microsoft Accounts re-enabled using the script below.

Disable a specific Microsoft user account on Windows

To disable any existing user account on the device, all you have to do is replace the value “User” with the corresponding account name in the following script and execute it from the console.

For example, provide the name of the account as in

Disable-LocalUser -Name "Serah"

You can fetch the actual name of the user by running this command:

Get-LocalUser

Also, re-enabling the given user account is relatively simpler. You may use the following script to achieve it.

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository