Windows way to Digital Learning……


Creating Bulk Users Using Power Shell.

#########################################################
#
# Name: BulkCreateUsers.ps1
# Author: Tony Murray
# Version: 1.0
# Date: 10/11/2009
# Description: PowerShell script to bulk create users
#
#########################################################

### Variables

# Get the logged-on user’s domain in DN form
$mydom = (get-addomain).distinguishedname

# Specify the OU we want to create the users in
$ouName = “User Accounts”

# Build the full DN of the target OU
$oudn = “OU=$ouname,$mydom”

# Specify the number of users to create
$userCount = 50

# Specify the description attribute for the users
$datetime = get-date -format G
$desc = “Test user created $datetime”

### Start doing things

# Check if the target OU exists. If not, create it.
$OU = get-adorganizationalunit -Filter { name -eq $ouname }
if($OU -eq $null)
{New-ADOrganizationalUnit -Name $OUName -Path $mydom}
else
{write-host “The OU” $ou “already exists – this is good…”}

# Create users

$i = 1
While ($i -le $usercount)
{
$Uname = “User” + $i
$UDdname = “Test User” + $i
New-ADUser –Name $Uname –SamAccountName $Uname –DisplayName $UDdname `
-Path $oudn –Enabled $true –ChangePasswordAtLogon $true -description $desc `
-AccountPassword (ConvertTo-SecureString “P@ssw0rd” -AsPlainText -force) -PassThru
$i = $i + 1
}

#End

Code taken from http://www.activedir.org

Download scripts by Andy Grogan.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: