How can I create a new user account on Windows 8 associated with a Microsoft email account?

How can I create a new local user account on Windows 8 associated with a Microsoft email account (e.g. MicrosoftAccount\[email protected]) programmatically, using PowerShell or another scripting language available on Windows. The script will be provided with the email address and password for the Microsoft account.

Thanks in advance for your help!


Windows accounts associated with Microsoft accounts are just normal Windows accounts with a little bit extra information added to them in the SAM.

You first use your favourite method to create your new accounts (net user, PowerShell, WMI) and then add the extra information to the new accounts.

This is actually rather tricky to do, because Microsoft does not provide a public API for it. Luckily someone did all the hard work for us. This blog post explains the details and provides a PowerShell script to add the additional information.