3 Create a user (the easy way)

 

This chapter covers:

  • Using Read-Host for user supplied data
  • Creating Menus with Read-Host and Write-Host
  • PowerShell pipe mechanism
  • Importing Modules
  • Active Directory cmdlets New-ADUser and Get-ADUser
  • Filtering AD Users with Where-Object
  • Introduction to Race Conditions.
  • Logging command history quickly and easily.

Adding users is a staple of a System Administrator’s world. The fact is, if there are not any users, there’s not really much point in having a system. Many systems have hundreds or even thousands of users. You can bet that nearly every one of them was created by a System Administrator. You can also bet that most of them were likely created by hand.

Most System Administrators view creating a user account as a rather trivial task, and by and large it is. But there are several required fields that make copy and pasting more than a little bit of a pain. Many companies, to save on onboarding costs typically have whole newhire classes. As such, it’s often that a System Administrator is not adding a single account, but often dozens at a time.

This usually involves:

3.1 Project Code

3.1.1 What does it do?

3.2 Comments

3.3 Input/Output

3.3.1 Read-Host

3.3.2 Menus

3.3.3 Output and Pipes

3.3.4 Pipe

3.3.5 Write-Output

3.3.6 Tee-Object

3.4 Get-ADUser

3.4.1 Active Directory Methods

3.5 New-ADUser

3.5.1 Where-Object

3.6 Start-Sleep

3.7 Putting it all together

3.7.1 Read-Host

3.7.2 Create a Username

3.7.3 Create a Log File

3.7.4 Write-Output

3.7.5 New-ADUser

3.7.6 Start-Sleep

3.7.7 Get-ADUser

3.8 Summary