Home » PowerShell » Creating Local Admins

Creating Local Admins

Recent Tweets

Enter your email address to follow this blog and receive notifications of new posts by email.


Here is a piece of code that will create a local user account and put it into the local Administrators group:

$computername = $env:computername   # place computername here for remote access

$username = ‘AdminAccountName’

$password = ‘yourpassword’

$desc = ‘Automatically created local admin account’

$computer = [ADSI]”WinNT://$computername,computer”

$user = $computer.Create(“user”, $username)



$user.description = $desc


$user.UserFlags = 65536


$group = [ADSI](“WinNT://$computername/administrators,group”)


You do need local Admin privileges to execute this script. Adjust the name of the “Administrators” group to match your locale.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: