How it works...

This recipe uses some AD cmdlets contained in the ActiveDirectory module. The recipe shows how to do basic management of AD objects using PowerShell.

In step 1, you create a hash table of common user properties. You use this hash table to hold some of the common user properties. There is no output from this step.

In step 2, you add two users to the AD. Note that the parameters to New-ADUser include the properties set in the $NewUserHT hash table and the parameters you specify when you call New-ADUser. Note that, by default, the Add-NewADUser adds the new user into the the Users container in the root of the AD. There is no output from this step, although you can observe the two newly added users using the Active Directory Users ...

Get Windows Server 2016 Automation with PowerShell Cookbook - Second Edition 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.