9 Making LOTS of users!

 

This chapter covers:

  • Additional Parameter options to collect credential objects and check for null values
  • Building a Windows dialogue box to explore for a file using the GUI
  • Using the While loop
  • A new way to check for empty or null strings
  • Reading data from a Comma Separated Value list (CSV)

In the last chapter, we took a big step forward in making our lives easier. We now have a script to create a user in our domain from start to finish with a single click and some simple values. This is great! But companies typically have some sort of onboarding procedure to bring batches of employees in at the same time. Thus, as an IT Professional, it’s far more common that you are creating new users in batches.

We have a script that will create a new user, but do we want to run it over and over, perhaps dozens of times? Isn’t there an easier way? There is!

This script will:

9.1 Project Code

9.2 More Parameters

9.2.1 Mandatory

9.2.2 Working with PSCredentials

9.2.3 System.Management.Automation.PSCredential

9.2.4 How we use this in our Tiny PowerShell Script

9.3 Creating Objects for GUI

9.3.1 .Net Assemblies

9.3.2 Dialog Boxes

9.3.3 How we use it in our script

9.4 More Loops

9.4.1 While Loop

9.4.2 How we use this in our script.

9.5 IsNullOrEmpty

9.5.1 Differences between Null and Empty

9.5.2 Checking for both nulls and empties

9.5.3 How we use it in our script.

9.6 Import-CSV

9.6.1 How we use it in our script

9.7 Targeting within the CSV

9.7.1 How we use this in our script

9.8 Summary