Now that we’ve learned to work with PowerShell variables and objects, let’s start to build something that might be useful in a competition like CyberPatriot.
In this Lab We Will:
- Learn the basics of user and group management within PowerShell.
Note: You’ll want to use this sheet as a reference point. Once we start writing an automation script, these commands and explanations will be very helpful!
Let’s start by creating a single local user on the system using the CLI.
To do this, let’s see what our old friend get-help has to say.
Get-Help New-LocalUser -online

It looks like New-LocalUser accepts several different parameters, but for this lab, we’ll just be using:
Creating Windows Passwords using PowerShell
Whenever you create or utilize a password within PowerShell, you must use the ConvertTo-SecureString cmdlet. (This is very common, and you’ll always see it used frequently when working with PowerShell.)
The get-help command above contains the following information:

The first step is to create a variable of type ‘SecureString’ that we want the user to have upon account creation. Here’s how we do that:
$password = ConvertTo-SecureString "Student123!" -AsPlainText -Force
Again, you will see this syntax frequently in the real world, as most of the time, passwords will be handled as ‘SecureStrings’ in PowerShell.
Now that we have a $password variable prepped, we can run New-LocalUser to create a new user on the system with a ‘Name’, ‘Password’, and ‘FullName’.