Creating Domain Groups

After creating users, the next step is to create groups to store the users. The CreateGroup.ps1 script is similar to the CreateUser.ps1 script examined in the "Creating Domain Users" section earlier in this chapter.

Begin the CreateGroup.ps1 script with a param() statement. Create one switch parameter named -help, and three other parameters that are used to create the group. This line of code is shown here:

param($name,$ou,$dc,[switch]$help)

Next, create the funhelp() function, which is used to display help. The here-string contains the description, parameters, and syntax of the script and is displayed when the script is run with the -help switch. This section of code is shown here:

function funHelp() { $helpText=@" DESCRIPTION: ...

Get Windows PowerShell™ Scripting Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.