In Server 2008, you can create multiple users by using the New-User cmdlet. This cmdlet allows you to create new users and assign them specific roles. You can also use the New-User cmdlet to change the user’s password and other settings. To create a new user in Server 2008, use the following command: New-User -Name “MyNewUser” -Role " Administrator" -Password “password” You can also use the New-User cmdlet to change the user’s password. To do this, use the following command: New-User -Name “MyNewUser” -PasswordChangeType “password_change”
We’ve just got a list of new employees from the HR Department, and they’ve been kind enough to give it to us in an excel format. Make sure that your own Excel file matches the same format, and make sure that you are using First Name and Last Name as column headers.
The first thing we are going to do is save the file as a .csv, and to do that, we click on the Office Button and select Save As.
We’re going to name our file users.csv, and make sure that we pick CSV (Comma delimited) in the Save as type box, and then click Save.
Next we’ll create a new text document on the server where we’ll be doing the user creation.
We’ll then copy the following into our new text document:
In the first line, make sure that you enter the correct information for your domain and the OU where you are creating the users. You’ll want to update the @sysadmingeek.com line as well to match your domain.
We then want to save the file as a PowerShell script, so we change the Save as type: to All Files (*), and name it PSusersScript.ps1.
Now we need to prep PowerShell to run scripts. You can launch PowerShell by clicking on the shortcut in the taskbar, or by typing PowerShell in the quick search box.
We need to change the Execution Policy to allow scripts to be run remotely, so we type
When prompted, we type Y and then hit enter to execute.
Now that we’ve allowed the script to be run, we need to place both the users.csv and the PSusersScript.ps1 files in our folder for execution. Since the PowerShell prompt naturally comes up to the root user folder, and we are logged on as Administrator, we are going to place them in the C:UsersAdministrator folder. When both files are in the folder, we right-click on the PSusersScript.ps1 file and choose Run with PowerShell.
If we take a look in AD Users and Computers, you will now see all those new users you just created.
The new users will be created in the lastname.firstname format, but the script could easily be altered to your need. Now that you’ve already created the script, all you have to do in the future is to place your list of users in the C:UsersAdministrator folder and run the PowerShell script. Easy!