Powershell: Create a new local admin user

I recently needed some code to create a quick local admin user on a Windows 10 machine. Here’s the Powershell code I used to create the account:

 

New-LocalUser -AccountNeverExpires:$true -Password ( ConvertTo-SecureString -AsPlainText -Force 'Password123!') -Name ‘Admin’ | Add-LocalGroupMember -Group administrators

 

You can amend the items in red to set your password and username.