How can I create a new local user account on Windows 8 associated with a Microsoft email account (e.g. MicrosoftAccount\someone@live.com) 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!

  • You're going to pre-create the email/MS accounts, and you're just looking to create a new Windows user and associate them to that email/MS account, correct? Have you tried using the traditional "Net User" command(s)? – Ƭᴇcʜιᴇ007 Jul 16 '13 at 18:17
  • 1
    @techie007 Yes, in the current case all Microsoft email accounts are already pre-created. But upon reading your comment, I realized it would be very useful for me to be able to create these accounts programmatically. So, if anybody know how to do that, please include it in your answer. Thanks! – Piotr Shatalin Jul 16 '13 at 18:27
  • Automating the creation of email accounts on MS's site would be off-topic for here, that's why I wanted to get clarification on what parts you are trying to automate. :) Aside form that, what exactly have you tried already? Where are you getting stuck in your scripting? – Ƭᴇcʜιᴇ007 Jul 16 '13 at 18:32
  • @techie007 I am quite a newbie in PowerShell scripting, basically only familiar with filesystem/registry/ACL manipulation, general pipelining and scripting constructs and .NET/COM interop. – Piotr Shatalin Jul 16 '13 at 19:38

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.


Yes, creating the Live account automatically is against TOS for the Live service thus off topic here. But I think what you are looking for is this:

# Create new local Admin user for script purposes
$Computer = [ADSI]"WinNT://$Env:COMPUTERNAME,Computer"

$LocalAdmin = $Computer.Create("User", "LocalAdmin")
$LocalAdmin.FullName = "Local Admin by Powershell"

Or you can use the old method:

Another alternative is the old school NET USER commands:

NET USER username "password" /ADD

OK - you can't set all the options but it's a lot less convoluted for simple user creation & easy to script up in Powershell.

NET LOCALGROUP "group" "user" /add to set group membership.
  • Where exactly in the script the user account being created is associated with a pre-created Microsoft e-mail account? I assume that the e-mail account password should be provided in some place, right? – Piotr Shatalin Aug 5 '13 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.