In: Computer Science
Hello,
#1 I am asked to create a Windows user account that is a non-admin user using a.ps1 file. At first, I used the New-LocalUser cmdlet, but this cmdlet does not show up as a user on the start menu of my computer and I cannot use it to log in as another user on my computer. So, instead of using that cmdlet, what could I use to create a Windows user account that I can also log into?
#2 I am asked to create a security group. Is 'New-LocalGroup -Name "SecurityGroup" the same cmdlet you use to create a security group?
I am then asked to add a member to the security group, is this how you do it? Add-LocalGroupMember -Group "SecurityGroup" -Member "NewMember01"
I wonder if this is correct because it seems as though I have only created a 'group' and not a 'security' group. If this is true, how could I create a security group?
Really appreciate your help!
Answer:
New-LocalUser "newUser" -FullName "New User" -Description "New user account created for test." -NoPassword
In order to add a new user named newUser please use the New-LocalUser command.
Kindly note that New-LocalUser just creates a user but doesn't add them to any group/security group. This is why you are not able to see newUser in the login option. You need to add user to a group in order to make it work.
Add-LocalGroupMember -Group "Users" -Member "newUser"
You can add user to Users group using this command, it has non-admin privileges. After adding it to the group Users, We can see the new user listed in start menu and User accounts.
You can find list of users using
Get-LocalUser
For second part of question:
Security groups are used give users access and limit the operations they can perform, so groups are the 'security' groups. The New-LocalGroup cmdlet creates a local security group in the Security Account Manager.
You can make a new security group and add new user by following commands:
New-LocalGroup -Name "SecurityGroup"
Add-LocalGroupMember -Group "SecurityGroup" -Member "newUser"
Kindly make sure you're running the .ps1 file from a user that has Administrator rights.
And run powershell as Administrator.
If you have any further questions, please comment on the answer, I will be happy to help.