Book Image

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

By : Thomas Lee, Ed Goad
Book Image

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

By: Thomas Lee, Ed Goad

Overview of this book

This book showcases several ways that Windows administrators can use to automate and streamline their job. You'll start with the PowerShell and Windows Server fundamentals, where you'll become well versed with PowerShell and Windows Server features. In the next module, Core Windows Server 2016, you'll implement Nano Server, manage Windows updates, and implement troubleshooting and server inventories. You'll then move on to the Networking module, where you'll manage Windows network services and network shares. The last module covers Azure and DSC, where you will use Azure on PowerShell and DSC to easily maintain Windows servers.
Table of Contents (21 chapters)
Title Page
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Creating and managing AD users, groups, and computers


Your active directory, as created in the Installing domain controllers and DNS recipe authenticates users and computers. AD also makes use of group membership to simplify authorization. In this recipe, you add, remove, and update users and computers. You also create and remove groups and manage group membership as well as manage organizational units. This recipe uses the cmdlets in the ActiveDirectory module. You can use a more automated approach to adding users by following the Adding users to the Active Directory using a CSV file recipe.

Getting ready

This recipe uses two working domain controllers (DC1 and DC2) in the Reskit.Org domain.

How to do it...

  1. Create a hash table for general user attributes:
$Password = 'Pa$$w0rd'$PasswordSS = ConvertTo-SecureString `
                      -String $Password `
                      -AsPlainText -Force$NewUserHT = @{}$NewUserHT.AccountPassword = $PasswordSS$NewUserHT.Enabled = $true$NewUserHT.PasswordNeverExpires...