top of page

Creating new users and adding to admin group with Powershell


I do love Powershell so it was an absolute joy to find out that in my latest University assignment I had to create some users using only Powershell and then add them to specific user groups. In this example Ive added "User5" to the administrators group.


This has all been done on an Azure VM running on remote desktop on my imac :)



The commands used are as follows:


1. Access PowerShell Click in OS search bar > type PowerShell > right click PowerShell icon and select 'run as administrator' 2. Create placeholders for username and password (note these are my choice of user and pass - replace with your own of course!) $username = "user3" $password = ConvertTo-SecureString "!nf0tecH" -AsPlainText -Force 3. Create user New-LocalUser -Name "$username" -Password $password -FullName "$username" -Description "User3" 4. Add a user to the administrators group Add-LocalGroupMember -Group "administrators" -Member "user3" 5. Check that user has been added, and added to the administrators group Get-LocalUser Get-LocalGroupMember administrators 6. Logout the current user and login as user3 to confirm access

2 views
bottom of page