Create Local Administrator Account
Explanation of the Script Steps
1. Account Details: The script defines the username and password for the new local administrator account. Change these values as needed.
2. Check for Existing Account: The script checks if a user account with the specified username already exists using Get-LocalUser.
3. Create New Account: If the account does not exist, it creates the new local user account with the specified password. The password is converted to a secure string for security purposes.
4. Add to Administrators Group: The script adds the new user to the “Administrators” group using Add-LocalGroupMember.
5. Output Message: The script outputs a message indicating whether the account was created or if it already exists.
Running the Script
1. Open PowerShell as an administrator.
2. Copy and paste the above script into the PowerShell window.
3. Modify the $username and $password variables as needed.
4. Press Enter to run the script.
Important Notes
• Password Security: Ensure you choose a strong password for the new administrator account.
• User Account Control (UAC): Make sure that your user account has the necessary permissions to create new local accounts.
• Running on Different Windows Versions: This script is compatible with Windows 10 and Windows Server 2016 and later.
Last updated