New

choubertsprojects

The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

We might not have to wait until 2027 for a flying car, but we may be forced to revise our goals and ambitions of what it means to “get where you want.”

New is a word that describes something that has recently been introduced or created. It can also be used to describe what is new in the world of technology. Read more in detail here: news.

New

Do you find yourself opening Active Directory (AD) Users and Computers (ADUC) for the sixth time today, scrolling about, making mistakes, and going through the motions of establishing a new user account? If that’s the case, you’ll need to utilize PowerShell’s New-ADUser cmdlet to automate the all-too-common task of utilizing Active Directory to create a user!

With Specops’ 100% free Password Auditor Pro, you can find, report, and prevent unsafe Active Directory account passwords in your environment. Now is the time to get it!

It’s Friday evening, and you have one hour till you leave for the weekend. You’ve had a long week and have chosen to watch the big game with your best buddies. Your supervisor, on the other hand, casually approaches you and says, “Did you receive the email?” Do you think you’ll be able to manage this at the end of the day? ” You open Microsoft Outlook fast, and sure enough, it’s an email from the HR department, with your boss cc’d, requesting you to setup 400 new employee Active Directory (AD) accounts before you leave the office. Great. That’s all for the game.

You promptly explore the Internet for ways to speed up the creation of these user accounts and learn that you can utilize the command line and a PowerShell cmdlet called New-ADUser to automate AD account provisioning.

Typically, administrators create AD accounts by hand using the Active Directory Users and Computers MMC snap-in, which is installed using Remote Server Administration Tools on your desktop computer (RSAT). However, establishing an AD user in this manner takes three minutes on average per user account. It’s not a glamorous profession, but it’s one that’s ripe for automation.

Using the New-AdUser cmdlet, administrators may create AD user account objects in three different methods.

  1. Using the needed and extra cmdlet options, create an Active Directory user account.
  2. Using the Instance argument, copy an existing AD user object to create a new account.
  3. To generate numerous Active Directory user objects from a comma-separated value (CSV) file, use the Import-Csv cmdlet in conjunction with the New-ADUser cmdlet.

These approaches may be combined to offer a more efficient solution in certain cases. For example, you may use all three methods to create a template AD account that can be replicated to create several new AD accounts using a CSV file.

You’ll learn how to utilize New-AdUser to take advantage of each of these approaches in this tutorial.

Prerequisites/Requirements

You must first confirm that you fulfill a few conditions before you can use the New-AdUser cmdlet.

  • PowerShell 5.1 is the latest version of Windows PowerShell.
  • Installed the Remote Server Administration Tools (RSAT) package. The Active Directory PowerShell module, which includes the New-AdUser cmdlet, is installed by this package.
  • You must be logged into a Windows computer that is part of the same domain as the user accounts you want to establish.
  • I’m logged in as an AD user account with the ability to create new accounts.

You’re good to go after you’ve met these conditions.

Using the New-ADUser cmdlet to create a single user account

Let’s start by creating a single user account to show how New-ADUser works at a fundamental level. You’ll notice that there aren’t many necessary parameters in New-ADUser. The Name parameter is the only one that is required, however it is seldom used alone.

When creating a user account, you’ll normally need a variety of parameters. Fortunately, the majority of the settings are self-explanatory and correspond to what you see in ADUC. As you can see in the example below, a large number of parameters may be used with ease. Each parameter corresponds to a particular user account property in a rough way.

In this example, we’re going to use backticks. This is only to avoid a lengthy single line for the sake of readability.

PS51> New-ADUser ` -Name “Kevin Sapp” ` -GivenName “Kevin” ` -Surname “Sapp” ` -SamAccountName “kesapp-test” ` -AccountPassword (Read-Host -AsSecureString “Input User Password”) ` -ChangePasswordAtLogon $True ` -Company “Code Duet” ` -Title “CEO” ` -State “California” ` -City “San Francisco” ` -Description “Test Account Creation” ` -EmployeeNumber “45” ` -Department “Engineering” ` -DisplayName “Kevin Sapp (Test)” ` -Country “us” ` -PostalCode “940001” ` -Enabled $True

There can’t be two SamAccountNames in the organizational unit (OU) that contains the AD user object.

Now that the account has been established, use the Get-ADUser cmdlet to verify that it was created correctly. Get-AdUser gives several typical properties for the newly established user account, as seen below.

PS51> Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City DistinguishedName : CN=Kevin Sapp,CN=Users,DC=mylab,DC=local Enabled : True GivenName : Kevin Name : Kevin Sapp ObjectClass : user ObjectGUID : 3b18338d-b3c7-4d00-a54a-1d3121e1363f SamAccountName : kesapp-test SID : S-1-5-21-1181311581-1397355964-1468337501-1109 Surname : Sapp UserPrincipalName : [email protected]al

Creating a New AD User Object from an Existing User Object

Another way to create a new AD account is to clone an existing AD user object and use it as a template. This method has a number of advantages:

  • It saves time by eliminating the need to provide each parameter separately.
  • It aids in the standardization of AD account creation.
  • It eliminates the risk of human error associated with manual account creation and enables colleagues on the same team to share specific AD characteristics.

You’ll use the account you just established as a template for this example (kesapp-test). Perhaps a new user account with the same state, location, department, nation, and city AD characteristics is required. This new account will be for James Brown, an employee.

This method has a restriction; only the AD account attributes specified in the URL below may be duplicated using this method. Check out the Microsoft documentation page Copy a User’s Properties for further details.

The first step is to locate the AD user account that will be used as a template, then double-check that the Properties parameter has all of the properties to duplicate. Use the Get-ADUser cmdlet to do this, as illustrated below. The $template account variable is just used to hold the AD user object.

The second line sets the UserPrincipalName (UPN) field of the template object to $null. To guarantee that the template’s UPN is unique, this is advised. A unique UPN is required for each AD user account.

Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City $template account = Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Once you’ve collected the template user account, you can use that object as the Instance parameter’s value and any user-specific arguments to fill in the other properties, as seen below.

-Name ‘James Brown”-SamAccountName ‘jbrown”New-ADUser’-Instance $template account’-Name ‘James Brown”-SamAccountName ‘jbrown’ ‘ ‘Read-Host -AsSecureString “Input User Password”) -AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The template object should now have created an account for James with all of the acceptable AD properties.

Gotchas in the User Account Template

When capturing the template object, one frequent error is to use the * wildcard for the Properties argument. This is done by administrators who wish to copy all of the user account properties at once. This, however, does not function.

The command below, for example, will result in an error:

Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance $template account = Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance ‘ -Name ‘James Brown”-SamAccountName ‘jbrown”-UserPrincipalName ‘[email protected]”-AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The issue with this method is that the UserPrincipalName property must be unique across the AD Forest. As a result, the UPN in the New-ADUser command should be rewritten or set to null in the template variable (shown below).

UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Another reason the wildcard technique fails is because some of the AD characteristics that the wildcard copies across are read-only (owned by the Security Account Manager).

When duplicating AD objects, there is a permission error.When duplicating AD objects, there is a permission error.

Using a CSV File to Create New User Accounts

Using what you’ve learned so far, you can read employee accounts from a CSV file and create AD user accounts using New-ADUser.

Many firms use this technology to automate account creation in combination with HR systems that generate flat files with new employee onboarding data.

Assume you’ve received a CSV file with a list of new workers. The CSV file comprises the following columns: FirstName, LastName, Department, State, EmployeeID, and Office, and each row represents a single row. The user login account is named using the employee’s first initial concatenated with his or her last name, such as ksapp for Kevin Sapp.

UserPrincipalName, SamAccountName, Password, FirstName, LastName, Department, State, EmployeeID, Office, UserPrincipalName, SamAccountName Micheal Jordan, NBA, Chicago Bulls, 23, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, LeBron James, NBA, Los Angeles, 24, LA Lakers, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames [email protected] Dwayne Wade, NBA, Miami, 13, Miami Heat, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade,

Use Import-Csv to read the CSV file and capture each row as a separate object once you have it. Then loop through those rows, providing the relevant information from the CSV file to New-anticipated ADUser’s arguments. Here’s an example of what I’m talking about.

Find leaked & unsafe passwords in your Active Directory by checking against the NCSC Password list.

$import users | ForEach-Object New-ADUser’-Name $(

Do you find yourself opening Active Directory (AD) Users and Computers (ADUC) for the sixth time today, scrolling about, making mistakes, and going through the motions of establishing a new user account? If that’s the case, you’ll need to utilize PowerShell’s New-ADUser cmdlet to automate the all-too-common task of utilizing Active Directory to create a user!

With Specops’ 100% free Password Auditor Pro, you can find, report, and prevent unsafe Active Directory account passwords in your environment. Now is the time to get it!

It’s Friday evening, and you have one hour till you leave for the weekend. You’ve had a long week and have chosen to watch the big game with your best buddies. Your supervisor, on the other hand, casually approaches you and says, “Did you receive the email?” Do you think you’ll be able to manage this at the end of the day? ” You open Microsoft Outlook fast, and sure enough, it’s an email from the HR department, with your boss cc’d, requesting you to setup 400 new employee Active Directory (AD) accounts before you leave the office. Great. That’s all for the game.

You promptly explore the Internet for ways to speed up the creation of these user accounts and learn that you can utilize the command line and a PowerShell cmdlet called New-ADUser to automate AD account provisioning.

Typically, administrators create AD accounts by hand using the Active Directory Users and Computers MMC snap-in, which is installed using Remote Server Administration Tools on your desktop computer (RSAT). However, establishing an AD user in this manner takes three minutes on average per user account. It’s not a glamorous profession, but it’s one that’s ripe for automation.

Using the New-AdUser cmdlet, administrators may create AD user account objects in three different methods.

  1. Using the needed and extra cmdlet options, create an Active Directory user account.
  2. Using the Instance argument, copy an existing AD user object to create a new account.
  3. To generate numerous Active Directory user objects from a comma-separated value (CSV) file, use the Import-Csv cmdlet in conjunction with the New-ADUser cmdlet.

These approaches may be combined to offer a more efficient solution in certain cases. For example, you may use all three methods to create a template AD account that can be replicated to create several new AD accounts using a CSV file.

You’ll learn how to utilize New-AdUser to take advantage of each of these approaches in this tutorial.

Prerequisites/Requirements

You must first confirm that you fulfill a few conditions before you can use the New-AdUser cmdlet.

  • PowerShell 5.1 is the latest version of Windows PowerShell.
  • Installed the Remote Server Administration Tools (RSAT) package. The Active Directory PowerShell module, which includes the New-AdUser cmdlet, is installed by this package.
  • You must be logged into a Windows computer that is part of the same domain as the user accounts you want to establish.
  • I’m logged in as an AD user account with the ability to create new accounts.

You’re good to go after you’ve met these conditions.

Using the New-ADUser cmdlet to create a single user account

Let’s start by creating a single user account to show how New-ADUser works at a fundamental level. You’ll notice that there aren’t many necessary parameters in New-ADUser. The Name parameter is the only one that is required, however it is seldom used alone.

When creating a user account, you’ll normally need a variety of parameters. Fortunately, the majority of the settings are self-explanatory and correspond to what you see in ADUC. As you can see in the example below, a large number of parameters may be used with ease. Each parameter corresponds to a particular user account property in a rough way.

In this example, we’re going to use backticks. This is only to avoid a lengthy single line for the sake of readability.

PS51> New-ADUser ` -Name “Kevin Sapp” ` -GivenName “Kevin” ` -Surname “Sapp” ` -SamAccountName “kesapp-test” ` -AccountPassword (Read-Host -AsSecureString “Input User Password”) ` -ChangePasswordAtLogon $True ` -Company “Code Duet” ` -Title “CEO” ` -State “California” ` -City “San Francisco” ` -Description “Test Account Creation” ` -EmployeeNumber “45” ` -Department “Engineering” ` -DisplayName “Kevin Sapp (Test)” ` -Country “us” ` -PostalCode “940001” ` -Enabled $True

There can’t be two SamAccountNames in the organizational unit (OU) that contains the AD user object.

Now that the account has been established, use the Get-ADUser cmdlet to verify that it was created correctly. Get-AdUser gives several typical properties for the newly established user account, as seen below.

PS51> Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City DistinguishedName : CN=Kevin Sapp,CN=Users,DC=mylab,DC=local Enabled : True GivenName : Kevin Name : Kevin Sapp ObjectClass : user ObjectGUID : 3b18338d-b3c7-4d00-a54a-1d3121e1363f SamAccountName : kesapp-test SID : S-1-5-21-1181311581-1397355964-1468337501-1109 Surname : Sapp UserPrincipalName : [email protected]al

Creating a New AD User Object from an Existing User Object

Another way to create a new AD account is to clone an existing AD user object and use it as a template. This method has a number of advantages:

  • It saves time by eliminating the need to provide each parameter separately.
  • It aids in the standardization of AD account creation.
  • It eliminates the risk of human error associated with manual account creation and enables colleagues on the same team to share specific AD characteristics.

You’ll use the account you just established as a template for this example (kesapp-test). Perhaps a new user account with the same state, location, department, nation, and city AD characteristics is required. This new account will be for James Brown, an employee.

This method has a restriction; only the AD account attributes specified in the URL below may be duplicated using this method. Check out the Microsoft documentation page Copy a User’s Properties for further details.

The first step is to locate the AD user account that will be used as a template, then double-check that the Properties parameter has all of the properties to duplicate. Use the Get-ADUser cmdlet to do this, as illustrated below. The $template account variable is just used to hold the AD user object.

The second line sets the UserPrincipalName (UPN) field of the template object to $null. To guarantee that the template’s UPN is unique, this is advised. A unique UPN is required for each AD user account.

Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City $template account = Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Once you’ve collected the template user account, you can use that object as the Instance parameter’s value and any user-specific arguments to fill in the other properties, as seen below.

-Name ‘James Brown”-SamAccountName ‘jbrown”New-ADUser’-Instance $template account’-Name ‘James Brown”-SamAccountName ‘jbrown’ ‘ ‘Read-Host -AsSecureString “Input User Password”) -AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The template object should now have created an account for James with all of the acceptable AD properties.

Gotchas in the User Account Template

When capturing the template object, one frequent error is to use the * wildcard for the Properties argument. This is done by administrators who wish to copy all of the user account properties at once. This, however, does not function.

The command below, for example, will result in an error:

Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance $template account = Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance ‘ -Name ‘James Brown”-SamAccountName ‘jbrown”-UserPrincipalName ‘[email protected]”-AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The issue with this method is that the UserPrincipalName property must be unique across the AD Forest. As a result, the UPN in the New-ADUser command should be rewritten or set to null in the template variable (shown below).

UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Another reason the wildcard technique fails is because some of the AD characteristics that the wildcard copies across are read-only (owned by the Security Account Manager).

When duplicating AD objects, there is a permission error.When duplicating AD objects, there is a permission error.

Using a CSV File to Create New User Accounts

Using what you’ve learned so far, you can read employee accounts from a CSV file and create AD user accounts using New-ADUser.

Many firms use this technology to automate account creation in combination with HR systems that generate flat files with new employee onboarding data.

Assume you’ve received a CSV file with a list of new workers. The CSV file comprises the following columns: FirstName, LastName, Department, State, EmployeeID, and Office, and each row represents a single row. The user login account is named using the employee’s first initial concatenated with his or her last name, such as ksapp for Kevin Sapp.

UserPrincipalName, SamAccountName, Password, FirstName, LastName, Department, State, EmployeeID, Office, UserPrincipalName, SamAccountName Micheal Jordan, NBA, Chicago Bulls, 23, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, LeBron James, NBA, Los Angeles, 24, LA Lakers, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames [email protected] Dwayne Wade, NBA, Miami, 13, Miami Heat, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade,

Use Import-Csv to read the CSV file and capture each row as a separate object once you have it. Then loop through those rows, providing the relevant information from the CSV file to New-anticipated ADUser’s arguments. Here’s an example of what I’m talking about.

Find leaked & unsafe passwords in your Active Directory by checking against the NCSC Password list.

$import_users | ForEach-Object { New-ADUser ` -Name $($_.FirstName + ” ” + $_.LastName) ` -GivenName $_.FirstName ` -Surname $_.LastName ` -Department $_.Department ` -State $_.State ` -EmployeeID $_.EmployeeID ` -DisplayName $($_.FirstName + ” ” + $_.LastName) ` -Office $_.Office ` -UserPrincipalName $_.UserPrincipalName ` -SamAccountName $_.SamAccountName ` -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force) ` -Enabled $True }

Summary

You learnt how to create new user accounts using three distinct approaches in this post:

  1. Creating a single account
  2. Using a template to create a user account
  3. Using a CSV file to create numerous accounts

These are the most basic methods for adding new users to your environment. When you combine these approaches into a PowerShell function and module, they’re fantastic. You may even go one step further and develop your own automation process based on a SQL or Oracle database (instead of a CSV file). Feel free to employ each strategy according to your own needs and scenarios.

Hopefully, this knowledge will come in handy in an emergency! You learnt a new skill and were able to attend your friends’ party without jeopardizing your work-life balance!

Additional Reading

.FirstName + ” ” +

Do you find yourself opening Active Directory (AD) Users and Computers (ADUC) for the sixth time today, scrolling about, making mistakes, and going through the motions of establishing a new user account? If that’s the case, you’ll need to utilize PowerShell’s New-ADUser cmdlet to automate the all-too-common task of utilizing Active Directory to create a user!

With Specops’ 100% free Password Auditor Pro, you can find, report, and prevent unsafe Active Directory account passwords in your environment. Now is the time to get it!

It’s Friday evening, and you have one hour till you leave for the weekend. You’ve had a long week and have chosen to watch the big game with your best buddies. Your supervisor, on the other hand, casually approaches you and says, “Did you receive the email?” Do you think you’ll be able to manage this at the end of the day? ” You open Microsoft Outlook fast, and sure enough, it’s an email from the HR department, with your boss cc’d, requesting you to setup 400 new employee Active Directory (AD) accounts before you leave the office. Great. That’s all for the game.

You promptly explore the Internet for ways to speed up the creation of these user accounts and learn that you can utilize the command line and a PowerShell cmdlet called New-ADUser to automate AD account provisioning.

Typically, administrators create AD accounts by hand using the Active Directory Users and Computers MMC snap-in, which is installed using Remote Server Administration Tools on your desktop computer (RSAT). However, establishing an AD user in this manner takes three minutes on average per user account. It’s not a glamorous profession, but it’s one that’s ripe for automation.

Using the New-AdUser cmdlet, administrators may create AD user account objects in three different methods.

  1. Using the needed and extra cmdlet options, create an Active Directory user account.
  2. Using the Instance argument, copy an existing AD user object to create a new account.
  3. To generate numerous Active Directory user objects from a comma-separated value (CSV) file, use the Import-Csv cmdlet in conjunction with the New-ADUser cmdlet.

These approaches may be combined to offer a more efficient solution in certain cases. For example, you may use all three methods to create a template AD account that can be replicated to create several new AD accounts using a CSV file.

You’ll learn how to utilize New-AdUser to take advantage of each of these approaches in this tutorial.

Prerequisites/Requirements

You must first confirm that you fulfill a few conditions before you can use the New-AdUser cmdlet.

  • PowerShell 5.1 is the latest version of Windows PowerShell.
  • Installed the Remote Server Administration Tools (RSAT) package. The Active Directory PowerShell module, which includes the New-AdUser cmdlet, is installed by this package.
  • You must be logged into a Windows computer that is part of the same domain as the user accounts you want to establish.
  • I’m logged in as an AD user account with the ability to create new accounts.

You’re good to go after you’ve met these conditions.

Using the New-ADUser cmdlet to create a single user account

Let’s start by creating a single user account to show how New-ADUser works at a fundamental level. You’ll notice that there aren’t many necessary parameters in New-ADUser. The Name parameter is the only one that is required, however it is seldom used alone.

When creating a user account, you’ll normally need a variety of parameters. Fortunately, the majority of the settings are self-explanatory and correspond to what you see in ADUC. As you can see in the example below, a large number of parameters may be used with ease. Each parameter corresponds to a particular user account property in a rough way.

In this example, we’re going to use backticks. This is only to avoid a lengthy single line for the sake of readability.

PS51> New-ADUser ` -Name “Kevin Sapp” ` -GivenName “Kevin” ` -Surname “Sapp” ` -SamAccountName “kesapp-test” ` -AccountPassword (Read-Host -AsSecureString “Input User Password”) ` -ChangePasswordAtLogon $True ` -Company “Code Duet” ` -Title “CEO” ` -State “California” ` -City “San Francisco” ` -Description “Test Account Creation” ` -EmployeeNumber “45” ` -Department “Engineering” ` -DisplayName “Kevin Sapp (Test)” ` -Country “us” ` -PostalCode “940001” ` -Enabled $True

There can’t be two SamAccountNames in the organizational unit (OU) that contains the AD user object.

Now that the account has been established, use the Get-ADUser cmdlet to verify that it was created correctly. Get-AdUser gives several typical properties for the newly established user account, as seen below.

PS51> Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City DistinguishedName : CN=Kevin Sapp,CN=Users,DC=mylab,DC=local Enabled : True GivenName : Kevin Name : Kevin Sapp ObjectClass : user ObjectGUID : 3b18338d-b3c7-4d00-a54a-1d3121e1363f SamAccountName : kesapp-test SID : S-1-5-21-1181311581-1397355964-1468337501-1109 Surname : Sapp UserPrincipalName : [email protected]al

Creating a New AD User Object from an Existing User Object

Another way to create a new AD account is to clone an existing AD user object and use it as a template. This method has a number of advantages:

  • It saves time by eliminating the need to provide each parameter separately.
  • It aids in the standardization of AD account creation.
  • It eliminates the risk of human error associated with manual account creation and enables colleagues on the same team to share specific AD characteristics.

You’ll use the account you just established as a template for this example (kesapp-test). Perhaps a new user account with the same state, location, department, nation, and city AD characteristics is required. This new account will be for James Brown, an employee.

This method has a restriction; only the AD account attributes specified in the URL below may be duplicated using this method. Check out the Microsoft documentation page Copy a User’s Properties for further details.

The first step is to locate the AD user account that will be used as a template, then double-check that the Properties parameter has all of the properties to duplicate. Use the Get-ADUser cmdlet to do this, as illustrated below. The $template account variable is just used to hold the AD user object.

The second line sets the UserPrincipalName (UPN) field of the template object to $null. To guarantee that the template’s UPN is unique, this is advised. A unique UPN is required for each AD user account.

Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City $template account = Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Once you’ve collected the template user account, you can use that object as the Instance parameter’s value and any user-specific arguments to fill in the other properties, as seen below.

-Name ‘James Brown”-SamAccountName ‘jbrown”New-ADUser’-Instance $template account’-Name ‘James Brown”-SamAccountName ‘jbrown’ ‘ ‘Read-Host -AsSecureString “Input User Password”) -AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The template object should now have created an account for James with all of the acceptable AD properties.

Gotchas in the User Account Template

When capturing the template object, one frequent error is to use the * wildcard for the Properties argument. This is done by administrators who wish to copy all of the user account properties at once. This, however, does not function.

The command below, for example, will result in an error:

Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance $template account = Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance ‘ -Name ‘James Brown”-SamAccountName ‘jbrown”-UserPrincipalName ‘[email protected]”-AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The issue with this method is that the UserPrincipalName property must be unique across the AD Forest. As a result, the UPN in the New-ADUser command should be rewritten or set to null in the template variable (shown below).

UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Another reason the wildcard technique fails is because some of the AD characteristics that the wildcard copies across are read-only (owned by the Security Account Manager).

When duplicating AD objects, there is a permission error.When duplicating AD objects, there is a permission error.

Using a CSV File to Create New User Accounts

Using what you’ve learned so far, you can read employee accounts from a CSV file and create AD user accounts using New-ADUser.

Many firms use this technology to automate account creation in combination with HR systems that generate flat files with new employee onboarding data.

Assume you’ve received a CSV file with a list of new workers. The CSV file comprises the following columns: FirstName, LastName, Department, State, EmployeeID, and Office, and each row represents a single row. The user login account is named using the employee’s first initial concatenated with his or her last name, such as ksapp for Kevin Sapp.

UserPrincipalName, SamAccountName, Password, FirstName, LastName, Department, State, EmployeeID, Office, UserPrincipalName, SamAccountName Micheal Jordan, NBA, Chicago Bulls, 23, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, LeBron James, NBA, Los Angeles, 24, LA Lakers, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames [email protected] Dwayne Wade, NBA, Miami, 13, Miami Heat, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade,

Use Import-Csv to read the CSV file and capture each row as a separate object once you have it. Then loop through those rows, providing the relevant information from the CSV file to New-anticipated ADUser’s arguments. Here’s an example of what I’m talking about.

Find leaked & unsafe passwords in your Active Directory by checking against the NCSC Password list.

$import_users | ForEach-Object { New-ADUser ` -Name $($_.FirstName + ” ” + $_.LastName) ` -GivenName $_.FirstName ` -Surname $_.LastName ` -Department $_.Department ` -State $_.State ` -EmployeeID $_.EmployeeID ` -DisplayName $($_.FirstName + ” ” + $_.LastName) ` -Office $_.Office ` -UserPrincipalName $_.UserPrincipalName ` -SamAccountName $_.SamAccountName ` -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force) ` -Enabled $True }

Summary

You learnt how to create new user accounts using three distinct approaches in this post:

  1. Creating a single account
  2. Using a template to create a user account
  3. Using a CSV file to create numerous accounts

These are the most basic methods for adding new users to your environment. When you combine these approaches into a PowerShell function and module, they’re fantastic. You may even go one step further and develop your own automation process based on a SQL or Oracle database (instead of a CSV file). Feel free to employ each strategy according to your own needs and scenarios.

Hopefully, this knowledge will come in handy in an emergency! You learnt a new skill and were able to attend your friends’ party without jeopardizing your work-life balance!

Additional Reading

.LastName)’-GivenName

Do you find yourself opening Active Directory (AD) Users and Computers (ADUC) for the sixth time today, scrolling about, making mistakes, and going through the motions of establishing a new user account? If that’s the case, you’ll need to utilize PowerShell’s New-ADUser cmdlet to automate the all-too-common task of utilizing Active Directory to create a user!

With Specops’ 100% free Password Auditor Pro, you can find, report, and prevent unsafe Active Directory account passwords in your environment. Now is the time to get it!

It’s Friday evening, and you have one hour till you leave for the weekend. You’ve had a long week and have chosen to watch the big game with your best buddies. Your supervisor, on the other hand, casually approaches you and says, “Did you receive the email?” Do you think you’ll be able to manage this at the end of the day? ” You open Microsoft Outlook fast, and sure enough, it’s an email from the HR department, with your boss cc’d, requesting you to setup 400 new employee Active Directory (AD) accounts before you leave the office. Great. That’s all for the game.

You promptly explore the Internet for ways to speed up the creation of these user accounts and learn that you can utilize the command line and a PowerShell cmdlet called New-ADUser to automate AD account provisioning.

Typically, administrators create AD accounts by hand using the Active Directory Users and Computers MMC snap-in, which is installed using Remote Server Administration Tools on your desktop computer (RSAT). However, establishing an AD user in this manner takes three minutes on average per user account. It’s not a glamorous profession, but it’s one that’s ripe for automation.

Using the New-AdUser cmdlet, administrators may create AD user account objects in three different methods.

  1. Using the needed and extra cmdlet options, create an Active Directory user account.
  2. Using the Instance argument, copy an existing AD user object to create a new account.
  3. To generate numerous Active Directory user objects from a comma-separated value (CSV) file, use the Import-Csv cmdlet in conjunction with the New-ADUser cmdlet.

These approaches may be combined to offer a more efficient solution in certain cases. For example, you may use all three methods to create a template AD account that can be replicated to create several new AD accounts using a CSV file.

You’ll learn how to utilize New-AdUser to take advantage of each of these approaches in this tutorial.

Prerequisites/Requirements

You must first confirm that you fulfill a few conditions before you can use the New-AdUser cmdlet.

  • PowerShell 5.1 is the latest version of Windows PowerShell.
  • Installed the Remote Server Administration Tools (RSAT) package. The Active Directory PowerShell module, which includes the New-AdUser cmdlet, is installed by this package.
  • You must be logged into a Windows computer that is part of the same domain as the user accounts you want to establish.
  • I’m logged in as an AD user account with the ability to create new accounts.

You’re good to go after you’ve met these conditions.

Using the New-ADUser cmdlet to create a single user account

Let’s start by creating a single user account to show how New-ADUser works at a fundamental level. You’ll notice that there aren’t many necessary parameters in New-ADUser. The Name parameter is the only one that is required, however it is seldom used alone.

When creating a user account, you’ll normally need a variety of parameters. Fortunately, the majority of the settings are self-explanatory and correspond to what you see in ADUC. As you can see in the example below, a large number of parameters may be used with ease. Each parameter corresponds to a particular user account property in a rough way.

In this example, we’re going to use backticks. This is only to avoid a lengthy single line for the sake of readability.

PS51> New-ADUser ` -Name “Kevin Sapp” ` -GivenName “Kevin” ` -Surname “Sapp” ` -SamAccountName “kesapp-test” ` -AccountPassword (Read-Host -AsSecureString “Input User Password”) ` -ChangePasswordAtLogon $True ` -Company “Code Duet” ` -Title “CEO” ` -State “California” ` -City “San Francisco” ` -Description “Test Account Creation” ` -EmployeeNumber “45” ` -Department “Engineering” ` -DisplayName “Kevin Sapp (Test)” ` -Country “us” ` -PostalCode “940001” ` -Enabled $True

There can’t be two SamAccountNames in the organizational unit (OU) that contains the AD user object.

Now that the account has been established, use the Get-ADUser cmdlet to verify that it was created correctly. Get-AdUser gives several typical properties for the newly established user account, as seen below.

PS51> Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City DistinguishedName : CN=Kevin Sapp,CN=Users,DC=mylab,DC=local Enabled : True GivenName : Kevin Name : Kevin Sapp ObjectClass : user ObjectGUID : 3b18338d-b3c7-4d00-a54a-1d3121e1363f SamAccountName : kesapp-test SID : S-1-5-21-1181311581-1397355964-1468337501-1109 Surname : Sapp UserPrincipalName : [email protected]al

Creating a New AD User Object from an Existing User Object

Another way to create a new AD account is to clone an existing AD user object and use it as a template. This method has a number of advantages:

  • It saves time by eliminating the need to provide each parameter separately.
  • It aids in the standardization of AD account creation.
  • It eliminates the risk of human error associated with manual account creation and enables colleagues on the same team to share specific AD characteristics.

You’ll use the account you just established as a template for this example (kesapp-test). Perhaps a new user account with the same state, location, department, nation, and city AD characteristics is required. This new account will be for James Brown, an employee.

This method has a restriction; only the AD account attributes specified in the URL below may be duplicated using this method. Check out the Microsoft documentation page Copy a User’s Properties for further details.

The first step is to locate the AD user account that will be used as a template, then double-check that the Properties parameter has all of the properties to duplicate. Use the Get-ADUser cmdlet to do this, as illustrated below. The $template account variable is just used to hold the AD user object.

The second line sets the UserPrincipalName (UPN) field of the template object to $null. To guarantee that the template’s UPN is unique, this is advised. A unique UPN is required for each AD user account.

Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City $template account = Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Once you’ve collected the template user account, you can use that object as the Instance parameter’s value and any user-specific arguments to fill in the other properties, as seen below.

-Name ‘James Brown”-SamAccountName ‘jbrown”New-ADUser’-Instance $template account’-Name ‘James Brown”-SamAccountName ‘jbrown’ ‘ ‘Read-Host -AsSecureString “Input User Password”) -AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The template object should now have created an account for James with all of the acceptable AD properties.

Gotchas in the User Account Template

When capturing the template object, one frequent error is to use the * wildcard for the Properties argument. This is done by administrators who wish to copy all of the user account properties at once. This, however, does not function.

The command below, for example, will result in an error:

Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance $template account = Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance ‘ -Name ‘James Brown”-SamAccountName ‘jbrown”-UserPrincipalName ‘[email protected]”-AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The issue with this method is that the UserPrincipalName property must be unique across the AD Forest. As a result, the UPN in the New-ADUser command should be rewritten or set to null in the template variable (shown below).

UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Another reason the wildcard technique fails is because some of the AD characteristics that the wildcard copies across are read-only (owned by the Security Account Manager).

When duplicating AD objects, there is a permission error.When duplicating AD objects, there is a permission error.

Using a CSV File to Create New User Accounts

Using what you’ve learned so far, you can read employee accounts from a CSV file and create AD user accounts using New-ADUser.

Many firms use this technology to automate account creation in combination with HR systems that generate flat files with new employee onboarding data.

Assume you’ve received a CSV file with a list of new workers. The CSV file comprises the following columns: FirstName, LastName, Department, State, EmployeeID, and Office, and each row represents a single row. The user login account is named using the employee’s first initial concatenated with his or her last name, such as ksapp for Kevin Sapp.

UserPrincipalName, SamAccountName, Password, FirstName, LastName, Department, State, EmployeeID, Office, UserPrincipalName, SamAccountName Micheal Jordan, NBA, Chicago Bulls, 23, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, LeBron James, NBA, Los Angeles, 24, LA Lakers, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames [email protected] Dwayne Wade, NBA, Miami, 13, Miami Heat, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade,

Use Import-Csv to read the CSV file and capture each row as a separate object once you have it. Then loop through those rows, providing the relevant information from the CSV file to New-anticipated ADUser’s arguments. Here’s an example of what I’m talking about.

Find leaked & unsafe passwords in your Active Directory by checking against the NCSC Password list.

$import_users | ForEach-Object { New-ADUser ` -Name $($_.FirstName + ” ” + $_.LastName) ` -GivenName $_.FirstName ` -Surname $_.LastName ` -Department $_.Department ` -State $_.State ` -EmployeeID $_.EmployeeID ` -DisplayName $($_.FirstName + ” ” + $_.LastName) ` -Office $_.Office ` -UserPrincipalName $_.UserPrincipalName ` -SamAccountName $_.SamAccountName ` -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force) ` -Enabled $True }

Summary

You learnt how to create new user accounts using three distinct approaches in this post:

  1. Creating a single account
  2. Using a template to create a user account
  3. Using a CSV file to create numerous accounts

These are the most basic methods for adding new users to your environment. When you combine these approaches into a PowerShell function and module, they’re fantastic. You may even go one step further and develop your own automation process based on a SQL or Oracle database (instead of a CSV file). Feel free to employ each strategy according to your own needs and scenarios.

Hopefully, this knowledge will come in handy in an emergency! You learnt a new skill and were able to attend your friends’ party without jeopardizing your work-life balance!

Additional Reading

.FirstName’-Surname

Do you find yourself opening Active Directory (AD) Users and Computers (ADUC) for the sixth time today, scrolling about, making mistakes, and going through the motions of establishing a new user account? If that’s the case, you’ll need to utilize PowerShell’s New-ADUser cmdlet to automate the all-too-common task of utilizing Active Directory to create a user!

With Specops’ 100% free Password Auditor Pro, you can find, report, and prevent unsafe Active Directory account passwords in your environment. Now is the time to get it!

It’s Friday evening, and you have one hour till you leave for the weekend. You’ve had a long week and have chosen to watch the big game with your best buddies. Your supervisor, on the other hand, casually approaches you and says, “Did you receive the email?” Do you think you’ll be able to manage this at the end of the day? ” You open Microsoft Outlook fast, and sure enough, it’s an email from the HR department, with your boss cc’d, requesting you to setup 400 new employee Active Directory (AD) accounts before you leave the office. Great. That’s all for the game.

You promptly explore the Internet for ways to speed up the creation of these user accounts and learn that you can utilize the command line and a PowerShell cmdlet called New-ADUser to automate AD account provisioning.

Typically, administrators create AD accounts by hand using the Active Directory Users and Computers MMC snap-in, which is installed using Remote Server Administration Tools on your desktop computer (RSAT). However, establishing an AD user in this manner takes three minutes on average per user account. It’s not a glamorous profession, but it’s one that’s ripe for automation.

Using the New-AdUser cmdlet, administrators may create AD user account objects in three different methods.

  1. Using the needed and extra cmdlet options, create an Active Directory user account.
  2. Using the Instance argument, copy an existing AD user object to create a new account.
  3. To generate numerous Active Directory user objects from a comma-separated value (CSV) file, use the Import-Csv cmdlet in conjunction with the New-ADUser cmdlet.

These approaches may be combined to offer a more efficient solution in certain cases. For example, you may use all three methods to create a template AD account that can be replicated to create several new AD accounts using a CSV file.

You’ll learn how to utilize New-AdUser to take advantage of each of these approaches in this tutorial.

Prerequisites/Requirements

You must first confirm that you fulfill a few conditions before you can use the New-AdUser cmdlet.

  • PowerShell 5.1 is the latest version of Windows PowerShell.
  • Installed the Remote Server Administration Tools (RSAT) package. The Active Directory PowerShell module, which includes the New-AdUser cmdlet, is installed by this package.
  • You must be logged into a Windows computer that is part of the same domain as the user accounts you want to establish.
  • I’m logged in as an AD user account with the ability to create new accounts.

You’re good to go after you’ve met these conditions.

Using the New-ADUser cmdlet to create a single user account

Let’s start by creating a single user account to show how New-ADUser works at a fundamental level. You’ll notice that there aren’t many necessary parameters in New-ADUser. The Name parameter is the only one that is required, however it is seldom used alone.

When creating a user account, you’ll normally need a variety of parameters. Fortunately, the majority of the settings are self-explanatory and correspond to what you see in ADUC. As you can see in the example below, a large number of parameters may be used with ease. Each parameter corresponds to a particular user account property in a rough way.

In this example, we’re going to use backticks. This is only to avoid a lengthy single line for the sake of readability.

PS51> New-ADUser ` -Name “Kevin Sapp” ` -GivenName “Kevin” ` -Surname “Sapp” ` -SamAccountName “kesapp-test” ` -AccountPassword (Read-Host -AsSecureString “Input User Password”) ` -ChangePasswordAtLogon $True ` -Company “Code Duet” ` -Title “CEO” ` -State “California” ` -City “San Francisco” ` -Description “Test Account Creation” ` -EmployeeNumber “45” ` -Department “Engineering” ` -DisplayName “Kevin Sapp (Test)” ` -Country “us” ` -PostalCode “940001” ` -Enabled $True

There can’t be two SamAccountNames in the organizational unit (OU) that contains the AD user object.

Now that the account has been established, use the Get-ADUser cmdlet to verify that it was created correctly. Get-AdUser gives several typical properties for the newly established user account, as seen below.

PS51> Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City DistinguishedName : CN=Kevin Sapp,CN=Users,DC=mylab,DC=local Enabled : True GivenName : Kevin Name : Kevin Sapp ObjectClass : user ObjectGUID : 3b18338d-b3c7-4d00-a54a-1d3121e1363f SamAccountName : kesapp-test SID : S-1-5-21-1181311581-1397355964-1468337501-1109 Surname : Sapp UserPrincipalName : [email protected]al

Creating a New AD User Object from an Existing User Object

Another way to create a new AD account is to clone an existing AD user object and use it as a template. This method has a number of advantages:

  • It saves time by eliminating the need to provide each parameter separately.
  • It aids in the standardization of AD account creation.
  • It eliminates the risk of human error associated with manual account creation and enables colleagues on the same team to share specific AD characteristics.

You’ll use the account you just established as a template for this example (kesapp-test). Perhaps a new user account with the same state, location, department, nation, and city AD characteristics is required. This new account will be for James Brown, an employee.

This method has a restriction; only the AD account attributes specified in the URL below may be duplicated using this method. Check out the Microsoft documentation page Copy a User’s Properties for further details.

The first step is to locate the AD user account that will be used as a template, then double-check that the Properties parameter has all of the properties to duplicate. Use the Get-ADUser cmdlet to do this, as illustrated below. The $template account variable is just used to hold the AD user object.

The second line sets the UserPrincipalName (UPN) field of the template object to $null. To guarantee that the template’s UPN is unique, this is advised. A unique UPN is required for each AD user account.

Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City $template account = Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Once you’ve collected the template user account, you can use that object as the Instance parameter’s value and any user-specific arguments to fill in the other properties, as seen below.

-Name ‘James Brown”-SamAccountName ‘jbrown”New-ADUser’-Instance $template account’-Name ‘James Brown”-SamAccountName ‘jbrown’ ‘ ‘Read-Host -AsSecureString “Input User Password”) -AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The template object should now have created an account for James with all of the acceptable AD properties.

Gotchas in the User Account Template

When capturing the template object, one frequent error is to use the * wildcard for the Properties argument. This is done by administrators who wish to copy all of the user account properties at once. This, however, does not function.

The command below, for example, will result in an error:

Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance $template account = Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance ‘ -Name ‘James Brown”-SamAccountName ‘jbrown”-UserPrincipalName ‘[email protected]”-AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The issue with this method is that the UserPrincipalName property must be unique across the AD Forest. As a result, the UPN in the New-ADUser command should be rewritten or set to null in the template variable (shown below).

UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Another reason the wildcard technique fails is because some of the AD characteristics that the wildcard copies across are read-only (owned by the Security Account Manager).

When duplicating AD objects, there is a permission error.When duplicating AD objects, there is a permission error.

Using a CSV File to Create New User Accounts

Using what you’ve learned so far, you can read employee accounts from a CSV file and create AD user accounts using New-ADUser.

Many firms use this technology to automate account creation in combination with HR systems that generate flat files with new employee onboarding data.

Assume you’ve received a CSV file with a list of new workers. The CSV file comprises the following columns: FirstName, LastName, Department, State, EmployeeID, and Office, and each row represents a single row. The user login account is named using the employee’s first initial concatenated with his or her last name, such as ksapp for Kevin Sapp.

UserPrincipalName, SamAccountName, Password, FirstName, LastName, Department, State, EmployeeID, Office, UserPrincipalName, SamAccountName Micheal Jordan, NBA, Chicago Bulls, 23, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, LeBron James, NBA, Los Angeles, 24, LA Lakers, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames [email protected] Dwayne Wade, NBA, Miami, 13, Miami Heat, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade,

Use Import-Csv to read the CSV file and capture each row as a separate object once you have it. Then loop through those rows, providing the relevant information from the CSV file to New-anticipated ADUser’s arguments. Here’s an example of what I’m talking about.

Find leaked & unsafe passwords in your Active Directory by checking against the NCSC Password list.

$import_users | ForEach-Object { New-ADUser ` -Name $($_.FirstName + ” ” + $_.LastName) ` -GivenName $_.FirstName ` -Surname $_.LastName ` -Department $_.Department ` -State $_.State ` -EmployeeID $_.EmployeeID ` -DisplayName $($_.FirstName + ” ” + $_.LastName) ` -Office $_.Office ` -UserPrincipalName $_.UserPrincipalName ` -SamAccountName $_.SamAccountName ` -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force) ` -Enabled $True }

Summary

You learnt how to create new user accounts using three distinct approaches in this post:

  1. Creating a single account
  2. Using a template to create a user account
  3. Using a CSV file to create numerous accounts

These are the most basic methods for adding new users to your environment. When you combine these approaches into a PowerShell function and module, they’re fantastic. You may even go one step further and develop your own automation process based on a SQL or Oracle database (instead of a CSV file). Feel free to employ each strategy according to your own needs and scenarios.

Hopefully, this knowledge will come in handy in an emergency! You learnt a new skill and were able to attend your friends’ party without jeopardizing your work-life balance!

Additional Reading

.LastName’-State

Do you find yourself opening Active Directory (AD) Users and Computers (ADUC) for the sixth time today, scrolling about, making mistakes, and going through the motions of establishing a new user account? If that’s the case, you’ll need to utilize PowerShell’s New-ADUser cmdlet to automate the all-too-common task of utilizing Active Directory to create a user!

With Specops’ 100% free Password Auditor Pro, you can find, report, and prevent unsafe Active Directory account passwords in your environment. Now is the time to get it!

It’s Friday evening, and you have one hour till you leave for the weekend. You’ve had a long week and have chosen to watch the big game with your best buddies. Your supervisor, on the other hand, casually approaches you and says, “Did you receive the email?” Do you think you’ll be able to manage this at the end of the day? ” You open Microsoft Outlook fast, and sure enough, it’s an email from the HR department, with your boss cc’d, requesting you to setup 400 new employee Active Directory (AD) accounts before you leave the office. Great. That’s all for the game.

You promptly explore the Internet for ways to speed up the creation of these user accounts and learn that you can utilize the command line and a PowerShell cmdlet called New-ADUser to automate AD account provisioning.

Typically, administrators create AD accounts by hand using the Active Directory Users and Computers MMC snap-in, which is installed using Remote Server Administration Tools on your desktop computer (RSAT). However, establishing an AD user in this manner takes three minutes on average per user account. It’s not a glamorous profession, but it’s one that’s ripe for automation.

Using the New-AdUser cmdlet, administrators may create AD user account objects in three different methods.

  1. Using the needed and extra cmdlet options, create an Active Directory user account.
  2. Using the Instance argument, copy an existing AD user object to create a new account.
  3. To generate numerous Active Directory user objects from a comma-separated value (CSV) file, use the Import-Csv cmdlet in conjunction with the New-ADUser cmdlet.

These approaches may be combined to offer a more efficient solution in certain cases. For example, you may use all three methods to create a template AD account that can be replicated to create several new AD accounts using a CSV file.

You’ll learn how to utilize New-AdUser to take advantage of each of these approaches in this tutorial.

Prerequisites/Requirements

You must first confirm that you fulfill a few conditions before you can use the New-AdUser cmdlet.

  • PowerShell 5.1 is the latest version of Windows PowerShell.
  • Installed the Remote Server Administration Tools (RSAT) package. The Active Directory PowerShell module, which includes the New-AdUser cmdlet, is installed by this package.
  • You must be logged into a Windows computer that is part of the same domain as the user accounts you want to establish.
  • I’m logged in as an AD user account with the ability to create new accounts.

You’re good to go after you’ve met these conditions.

Using the New-ADUser cmdlet to create a single user account

Let’s start by creating a single user account to show how New-ADUser works at a fundamental level. You’ll notice that there aren’t many necessary parameters in New-ADUser. The Name parameter is the only one that is required, however it is seldom used alone.

When creating a user account, you’ll normally need a variety of parameters. Fortunately, the majority of the settings are self-explanatory and correspond to what you see in ADUC. As you can see in the example below, a large number of parameters may be used with ease. Each parameter corresponds to a particular user account property in a rough way.

In this example, we’re going to use backticks. This is only to avoid a lengthy single line for the sake of readability.

PS51> New-ADUser ` -Name “Kevin Sapp” ` -GivenName “Kevin” ` -Surname “Sapp” ` -SamAccountName “kesapp-test” ` -AccountPassword (Read-Host -AsSecureString “Input User Password”) ` -ChangePasswordAtLogon $True ` -Company “Code Duet” ` -Title “CEO” ` -State “California” ` -City “San Francisco” ` -Description “Test Account Creation” ` -EmployeeNumber “45” ` -Department “Engineering” ` -DisplayName “Kevin Sapp (Test)” ` -Country “us” ` -PostalCode “940001” ` -Enabled $True

There can’t be two SamAccountNames in the organizational unit (OU) that contains the AD user object.

Now that the account has been established, use the Get-ADUser cmdlet to verify that it was created correctly. Get-AdUser gives several typical properties for the newly established user account, as seen below.

PS51> Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City DistinguishedName : CN=Kevin Sapp,CN=Users,DC=mylab,DC=local Enabled : True GivenName : Kevin Name : Kevin Sapp ObjectClass : user ObjectGUID : 3b18338d-b3c7-4d00-a54a-1d3121e1363f SamAccountName : kesapp-test SID : S-1-5-21-1181311581-1397355964-1468337501-1109 Surname : Sapp UserPrincipalName : [email protected]al

Creating a New AD User Object from an Existing User Object

Another way to create a new AD account is to clone an existing AD user object and use it as a template. This method has a number of advantages:

  • It saves time by eliminating the need to provide each parameter separately.
  • It aids in the standardization of AD account creation.
  • It eliminates the risk of human error associated with manual account creation and enables colleagues on the same team to share specific AD characteristics.

You’ll use the account you just established as a template for this example (kesapp-test). Perhaps a new user account with the same state, location, department, nation, and city AD characteristics is required. This new account will be for James Brown, an employee.

This method has a restriction; only the AD account attributes specified in the URL below may be duplicated using this method. Check out the Microsoft documentation page Copy a User’s Properties for further details.

The first step is to locate the AD user account that will be used as a template, then double-check that the Properties parameter has all of the properties to duplicate. Use the Get-ADUser cmdlet to do this, as illustrated below. The $template account variable is just used to hold the AD user object.

The second line sets the UserPrincipalName (UPN) field of the template object to $null. To guarantee that the template’s UPN is unique, this is advised. A unique UPN is required for each AD user account.

Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City $template account = Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Once you’ve collected the template user account, you can use that object as the Instance parameter’s value and any user-specific arguments to fill in the other properties, as seen below.

-Name ‘James Brown”-SamAccountName ‘jbrown”New-ADUser’-Instance $template account’-Name ‘James Brown”-SamAccountName ‘jbrown’ ‘ ‘Read-Host -AsSecureString “Input User Password”) -AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The template object should now have created an account for James with all of the acceptable AD properties.

Gotchas in the User Account Template

When capturing the template object, one frequent error is to use the * wildcard for the Properties argument. This is done by administrators who wish to copy all of the user account properties at once. This, however, does not function.

The command below, for example, will result in an error:

Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance $template account = Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance ‘ -Name ‘James Brown”-SamAccountName ‘jbrown”-UserPrincipalName ‘[email protected]”-AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The issue with this method is that the UserPrincipalName property must be unique across the AD Forest. As a result, the UPN in the New-ADUser command should be rewritten or set to null in the template variable (shown below).

UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Another reason the wildcard technique fails is because some of the AD characteristics that the wildcard copies across are read-only (owned by the Security Account Manager).

When duplicating AD objects, there is a permission error.When duplicating AD objects, there is a permission error.

Using a CSV File to Create New User Accounts

Using what you’ve learned so far, you can read employee accounts from a CSV file and create AD user accounts using New-ADUser.

Many firms use this technology to automate account creation in combination with HR systems that generate flat files with new employee onboarding data.

Assume you’ve received a CSV file with a list of new workers. The CSV file comprises the following columns: FirstName, LastName, Department, State, EmployeeID, and Office, and each row represents a single row. The user login account is named using the employee’s first initial concatenated with his or her last name, such as ksapp for Kevin Sapp.

UserPrincipalName, SamAccountName, Password, FirstName, LastName, Department, State, EmployeeID, Office, UserPrincipalName, SamAccountName Micheal Jordan, NBA, Chicago Bulls, 23, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, LeBron James, NBA, Los Angeles, 24, LA Lakers, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames [email protected] Dwayne Wade, NBA, Miami, 13, Miami Heat, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade,

Use Import-Csv to read the CSV file and capture each row as a separate object once you have it. Then loop through those rows, providing the relevant information from the CSV file to New-anticipated ADUser’s arguments. Here’s an example of what I’m talking about.

Find leaked & unsafe passwords in your Active Directory by checking against the NCSC Password list.

$import_users | ForEach-Object { New-ADUser ` -Name $($_.FirstName + ” ” + $_.LastName) ` -GivenName $_.FirstName ` -Surname $_.LastName ` -Department $_.Department ` -State $_.State ` -EmployeeID $_.EmployeeID ` -DisplayName $($_.FirstName + ” ” + $_.LastName) ` -Office $_.Office ` -UserPrincipalName $_.UserPrincipalName ` -SamAccountName $_.SamAccountName ` -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force) ` -Enabled $True }

Summary

You learnt how to create new user accounts using three distinct approaches in this post:

  1. Creating a single account
  2. Using a template to create a user account
  3. Using a CSV file to create numerous accounts

These are the most basic methods for adding new users to your environment. When you combine these approaches into a PowerShell function and module, they’re fantastic. You may even go one step further and develop your own automation process based on a SQL or Oracle database (instead of a CSV file). Feel free to employ each strategy according to your own needs and scenarios.

Hopefully, this knowledge will come in handy in an emergency! You learnt a new skill and were able to attend your friends’ party without jeopardizing your work-life balance!

Additional Reading

.State’-EmployeeID

Do you find yourself opening Active Directory (AD) Users and Computers (ADUC) for the sixth time today, scrolling about, making mistakes, and going through the motions of establishing a new user account? If that’s the case, you’ll need to utilize PowerShell’s New-ADUser cmdlet to automate the all-too-common task of utilizing Active Directory to create a user!

With Specops’ 100% free Password Auditor Pro, you can find, report, and prevent unsafe Active Directory account passwords in your environment. Now is the time to get it!

It’s Friday evening, and you have one hour till you leave for the weekend. You’ve had a long week and have chosen to watch the big game with your best buddies. Your supervisor, on the other hand, casually approaches you and says, “Did you receive the email?” Do you think you’ll be able to manage this at the end of the day? ” You open Microsoft Outlook fast, and sure enough, it’s an email from the HR department, with your boss cc’d, requesting you to setup 400 new employee Active Directory (AD) accounts before you leave the office. Great. That’s all for the game.

You promptly explore the Internet for ways to speed up the creation of these user accounts and learn that you can utilize the command line and a PowerShell cmdlet called New-ADUser to automate AD account provisioning.

Typically, administrators create AD accounts by hand using the Active Directory Users and Computers MMC snap-in, which is installed using Remote Server Administration Tools on your desktop computer (RSAT). However, establishing an AD user in this manner takes three minutes on average per user account. It’s not a glamorous profession, but it’s one that’s ripe for automation.

Using the New-AdUser cmdlet, administrators may create AD user account objects in three different methods.

  1. Using the needed and extra cmdlet options, create an Active Directory user account.
  2. Using the Instance argument, copy an existing AD user object to create a new account.
  3. To generate numerous Active Directory user objects from a comma-separated value (CSV) file, use the Import-Csv cmdlet in conjunction with the New-ADUser cmdlet.

These approaches may be combined to offer a more efficient solution in certain cases. For example, you may use all three methods to create a template AD account that can be replicated to create several new AD accounts using a CSV file.

You’ll learn how to utilize New-AdUser to take advantage of each of these approaches in this tutorial.

Prerequisites/Requirements

You must first confirm that you fulfill a few conditions before you can use the New-AdUser cmdlet.

  • PowerShell 5.1 is the latest version of Windows PowerShell.
  • Installed the Remote Server Administration Tools (RSAT) package. The Active Directory PowerShell module, which includes the New-AdUser cmdlet, is installed by this package.
  • You must be logged into a Windows computer that is part of the same domain as the user accounts you want to establish.
  • I’m logged in as an AD user account with the ability to create new accounts.

You’re good to go after you’ve met these conditions.

Using the New-ADUser cmdlet to create a single user account

Let’s start by creating a single user account to show how New-ADUser works at a fundamental level. You’ll notice that there aren’t many necessary parameters in New-ADUser. The Name parameter is the only one that is required, however it is seldom used alone.

When creating a user account, you’ll normally need a variety of parameters. Fortunately, the majority of the settings are self-explanatory and correspond to what you see in ADUC. As you can see in the example below, a large number of parameters may be used with ease. Each parameter corresponds to a particular user account property in a rough way.

In this example, we’re going to use backticks. This is only to avoid a lengthy single line for the sake of readability.

PS51> New-ADUser ` -Name “Kevin Sapp” ` -GivenName “Kevin” ` -Surname “Sapp” ` -SamAccountName “kesapp-test” ` -AccountPassword (Read-Host -AsSecureString “Input User Password”) ` -ChangePasswordAtLogon $True ` -Company “Code Duet” ` -Title “CEO” ` -State “California” ` -City “San Francisco” ` -Description “Test Account Creation” ` -EmployeeNumber “45” ` -Department “Engineering” ` -DisplayName “Kevin Sapp (Test)” ` -Country “us” ` -PostalCode “940001” ` -Enabled $True

There can’t be two SamAccountNames in the organizational unit (OU) that contains the AD user object.

Now that the account has been established, use the Get-ADUser cmdlet to verify that it was created correctly. Get-AdUser gives several typical properties for the newly established user account, as seen below.

PS51> Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City DistinguishedName : CN=Kevin Sapp,CN=Users,DC=mylab,DC=local Enabled : True GivenName : Kevin Name : Kevin Sapp ObjectClass : user ObjectGUID : 3b18338d-b3c7-4d00-a54a-1d3121e1363f SamAccountName : kesapp-test SID : S-1-5-21-1181311581-1397355964-1468337501-1109 Surname : Sapp UserPrincipalName : [email protected]al

Creating a New AD User Object from an Existing User Object

Another way to create a new AD account is to clone an existing AD user object and use it as a template. This method has a number of advantages:

  • It saves time by eliminating the need to provide each parameter separately.
  • It aids in the standardization of AD account creation.
  • It eliminates the risk of human error associated with manual account creation and enables colleagues on the same team to share specific AD characteristics.

You’ll use the account you just established as a template for this example (kesapp-test). Perhaps a new user account with the same state, location, department, nation, and city AD characteristics is required. This new account will be for James Brown, an employee.

This method has a restriction; only the AD account attributes specified in the URL below may be duplicated using this method. Check out the Microsoft documentation page Copy a User’s Properties for further details.

The first step is to locate the AD user account that will be used as a template, then double-check that the Properties parameter has all of the properties to duplicate. Use the Get-ADUser cmdlet to do this, as illustrated below. The $template account variable is just used to hold the AD user object.

The second line sets the UserPrincipalName (UPN) field of the template object to $null. To guarantee that the template’s UPN is unique, this is advised. A unique UPN is required for each AD user account.

Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City $template account = Get-ADUser -Identity kesapp-test -Properties State,Department,Country,City UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Once you’ve collected the template user account, you can use that object as the Instance parameter’s value and any user-specific arguments to fill in the other properties, as seen below.

-Name ‘James Brown”-SamAccountName ‘jbrown”New-ADUser’-Instance $template account’-Name ‘James Brown”-SamAccountName ‘jbrown’ ‘ ‘Read-Host -AsSecureString “Input User Password”) -AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The template object should now have created an account for James with all of the acceptable AD properties.

Gotchas in the User Account Template

When capturing the template object, one frequent error is to use the * wildcard for the Properties argument. This is done by administrators who wish to copy all of the user account properties at once. This, however, does not function.

The command below, for example, will result in an error:

Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance $template account = Get-ADUser -Identity kesapp-test -Properties * New-ADUser’-Instance ‘ -Name ‘James Brown”-SamAccountName ‘jbrown”-UserPrincipalName ‘[email protected]”-AccountPassword (Read-Host -AsSecureString “Input User Password”)’-Enabled $True

The issue with this method is that the UserPrincipalName property must be unique across the AD Forest. As a result, the UPN in the New-ADUser command should be rewritten or set to null in the template variable (shown below).

UserPrincipalName = $null; $template account.UserPrincipalName = $null; $template account.UserPrincipal

Another reason the wildcard technique fails is because some of the AD characteristics that the wildcard copies across are read-only (owned by the Security Account Manager).

When duplicating AD objects, there is a permission error.When duplicating AD objects, there is a permission error.

Using a CSV File to Create New User Accounts

Using what you’ve learned so far, you can read employee accounts from a CSV file and create AD user accounts using New-ADUser.

Many firms use this technology to automate account creation in combination with HR systems that generate flat files with new employee onboarding data.

Assume you’ve received a CSV file with a list of new workers. The CSV file comprises the following columns: FirstName, LastName, Department, State, EmployeeID, and Office, and each row represents a single row. The user login account is named using the employee’s first initial concatenated with his or her last name, such as ksapp for Kevin Sapp.

UserPrincipalName, SamAccountName, Password, FirstName, LastName, Department, State, EmployeeID, Office, UserPrincipalName, SamAccountName Micheal Jordan, NBA, Chicago Bulls, 23, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, mjordan, LeBron James, NBA, Los Angeles, 24, LA Lakers, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames, ljames [email protected] Dwayne Wade, NBA, Miami, 13, Miami Heat, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade, dwade,

Use Import-Csv to read the CSV file and capture each row as a separate object once you have it. Then loop through those rows, providing the relevant information from the CSV file to New-anticipated ADUser’s arguments. Here’s an example of what I’m talking about.

Find leaked & unsafe passwords in your Active Directory by checking against the NCSC Password list.

$import_users | ForEach-Object { New-ADUser ` -Name $($_.FirstName + ” ” + $_.LastName) ` -GivenName $_.FirstName ` -Surname $_.LastName ` -Department $_.Department ` -State $_.State ` -EmployeeID $_.EmployeeID ` -DisplayName $($_.FirstName + ” ” + $_.LastName) ` -Office $_.Office ` -UserPrincipalName $_.UserPrincipalName ` -SamAccountName $_.SamAccountName ` -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force) ` -Enabled $True }

Summary

You learnt how to create new user accounts using three distinct approaches in this post:

  1. Creating a single account
  2. Using a template to create a user account
  3. Using a CSV file to create numerous accounts

These are the most basic methods for adding new users to your environment. When you combine these approaches into a PowerShell function and module, they’re fantastic. You may even go one step further and develop your own automation process based on a SQL or Oracle database (instead of a CSV file). Feel free to employ each strategy according to your own needs and scenarios.

Hopefully, this knowledge will come in handy in an emergency! You learnt a new skill and were able to attend your friends’ party without jeopardizing your work-life balance!

Additional Reading

.EmployeeID ‘ $False

Summary

You learnt how to create new user accounts using three distinct approaches in this post:

  1. Creating a single account
  2. Using a template to create a user account
  3. Using a CSV file to create numerous accounts

These are the most basic methods for adding new users to your environment. When you combine these approaches into a PowerShell function and module, they’re fantastic. You may even go one step further and develop your own automation process based on a SQL or Oracle database (instead of a CSV file). Feel free to employ each strategy according to your own needs and scenarios.

Hopefully, this knowledge will come in handy in an emergency! You learnt a new skill and were able to attend your friends’ party without jeopardizing your work-life balance!

Additional Reading

The “new yorker” is a newspaper in the United States. It was founded in 1857 and has been published continuously since then. The paper is known for its liberal editorial stance and covers many topics, including politics, culture, finance, and international news.

Related Tags

  • news today
  • new york times
  • new news
  • new scientist
  • new york post

Table of Content