Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Windows Server 2016 Automation with PowerShell Cookbook

You're reading from   Windows Server 2016 Automation with PowerShell Cookbook Powerful ways to automate and manage Windows administrative tasks

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher
ISBN-13 9781787122048
Length 660 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Thomas Lee Thomas Lee
Author Profile Icon Thomas Lee
Thomas Lee
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. What's New in PowerShell and Windows Server FREE CHAPTER 2. Implementing Nano Server 3. Managing Windows Updates 4. Managing Printers 5. Managing Server Backup 6. Managing Performance 7. Troubleshooting Windows Server 2016 8. Managing Windows Networking Services 9. Managing Network Shares 10. Managing Internet Information Server 11. Managing Hyper-V 12. Managing Azure 13. Using Desired State Configuration

Getting the most from this book

This book was written based on some assumptions and with some constraints. You will need to read this section to understand how I intended the book to be used and what I have assumed about you. This should help you to get the most from this book.

  1. The first assumption I made in writing this book is that you know the basics of PowerShell. This is not a PowerShell tutorial. The recipes do make use of a wide range of PowerShell features, including WMI, Remoting, AD and so on, but you will need to know the basics of PowerShell. The book uses PowerShell language, syntax, and cmdlets that come with Windows Server 2016 and Windows 10 (CU).
  1. The recipes provide the basics—you adopt and adapt. The recipes are designed to show you the basics of how to manage certain aspects of Windows Server 2016 using PowerShell (and in some cases Windows Console Applications). In many cases, a recipe stresses that you can improve it for your environment. The recipe is meant to show you how some features work, so you can leverage and extend it for your environment.
  2. Start by running the recipes step by step. The recipes were built and tested step by step. Once you have it working, re-factor them into your own reusable functions. In some cases, we build simple functions as a guide to richer scripts you could build.
  3. Writing PowerShell scripts for publication in a book is a layout nightmare. To get around this, I have made extensive use of the various ways in which you can create multiline commands within PowerShell. This involves using the back tick (`) line continuation as well as using the Pipe character at the end of the line. I also sometimes specify an array of values across multiple lines with a comma at the end of the continuing line. Hopefully, the screenshots more or less match up. So, read the text carefully and pay attention particularly to the back tick. In all too many places and to save lots of extra blank space, code spills over a page break, or where a figure and related text are split across a page boundary. I hope there are not too many issues with layout!
  1. Many of the cmdlet or object methods used in this book produce output that may not be all that helpful or useful. In some cases, the output generates a lot of pages of little value. For this reason, many recipes pipe to Out-Null. Feel free to remove this where you want to see more details. In some cases, I have adjusted the output to avoid wasted white space. Thus, if you test a recipe, you may see the output that is laid out a bit differently, but it should contain the same information. Of course, the specific output you see may be different based on your environment and the specific values you use in each step.
  2. To write this book, I have used a large VM farm consisting of over 20 Windows 2016 servers and Windows 10 clients. All the hosts used in this book are a combination of some physical hardware (running almost entirely on Windows 10 Creators Update and a large set of VMs, including the following:
    • Domain Controllers (DC1, DC2)—also hosts DHCP Server, IIS, and other roles).
    • File Servers (FS1, FS1)
    • Network Load Balanced IIS servers (NLB1, NLB2)
    • Print Server (PSrv)
    • General purpose servers (SRV1, SRV2)
    • Client computers (CL1, SG-BR-CL1)
    • Certificate servers (root, CA)
    • Hyper-V Servers (HV1, HV1), including an embedded VM, VM1.

Each recipe notes the servers in use. Feel free to change things to suit your needs and based on your own naming conventions.

  1. In building the VM farm, I have used an IP address block of 10.10.10.0/24. The recipes show specific addresses in use, but you can adapt these to fit your environment. The IP addresses used are assigned as follows:

IP address

Server name

10.10.10.10

DC1 (DC, DHCP, DNS, IIS, and so on)

10.10.10.11

DC2 (DC, DHCP, and DNS)

10.10.10.20

Root (CA offline root)

10.10.10.21

CA.Reskit.Org—issuing CA

10.10.10.50

SRV1 (server with numerous roles)

10.10.10.51

10.10.10.55

SRV2 (server with numerous roles)

ReskitNLB (NLB Virtual Server)

10.10.10.60

PSRV (print server)

10.10.10.61

Sales.Reskit.Org—a network printer

10.10.10.62

Sales2.reskit.org—a printer at as remote office

10.10.10.100

FS.Reskit.Org (Cluster address)

10.10.10.101/102

FS1 (file server cluster node—with 2 nics)

10.10.10.105/106

FS2 (file server cluster node—with w nics)

10.10.10.131

Nano1

10.10.10.132

Nano2

10.10.10.141

SG-CL1 (client computer in the Sales Group)

10.10.10.146

SG-BR-CL1 (sales group branch office client)

10.10.10.201

HV1 (Hyper-V server)

10.10.10.202

HV2 (Hyper-V server)

10.10.10.251

WSUS1 (WSUS Server)

10.10.10.254

Default gateway

 

The full set of VMs, at the end of this writing, took up around 725 GB of storage. Fortunately, storage is cheap!

  1. PowerShell provides great feature coverage—you can manage most of the functions and features of Windows Server 2016 using PowerShell, but by no means all. In some cases, you can dip down into WMI using the CIM cmdlets to get to object properties and methods not exposed by any cmdlet. The advent of CDXML-based cmdlets has increased the number of networking and other cmdlets that are WMI-based. But even then, there are still a number of places where you need to use a Windows console application or invoke an unmanaged DLL. The bottom line is that to manage some aspects of Windows, such as event forwarding or performance logging, you will need to use older tools. We try to avoid these, but in many cases the recipe demonstrates how to use the console applications within PowerShell.
  2. I have avoided where possible using external, third-party modules and have focused on what comes in the box. But, in some cases, such as Azure, you have to add code and in other cases such as DSC you benefit greatly from third-party code. The book shows that there is a wealth of tools, add-ins, and tips/tricks that you can leverage (even if we do not use all that much of it). One thing to keep in mind, integrating various add-ons (and keeping them up to date and working well) can be a challenge.
  3. All the code provided in this book has been tested; it worked and did what it
    says (at least during the writing stage). The production process is complex and it's possible that errors in code creep in during the production stages. Some of the more complex steps may have errors introduced during production. If any step fails for you, please contact PACKT and we'll help. Feel free to post issues to the Spiceworks PowerShell forum for quick resolution.
  4. In writing this book, we set out to create content around a number of features of Windows Server 2016. As the book progressed, we quickly hit (and broke) several content limits. In order to publish the book, it was necessary to remove some content, which we did most reluctantly. Coverage of Storage and Containers had to be dropped. To paraphrase Jeffrey Snover, To ship is to choose. I hope I chose well.
  1. In writing the recipes, we use full cmdlet names with no aliases and with all parameter names spelled out in full (so, this means no abbreviated parameter names or positional parameters). This makes the text a bit longer, but hopefully easier to read and understand.
  2. Some recipes in this book rely on other recipes being completed. These related recipes worked well when we wrote them and hopefully will work for you as well. Each depending recipe is noted.
  3. There is a fine line between PowerShell and a Windows feature. To use PowerShell to manage a Windows feature, you need to understand the feature itself. The chapters describe each feature although in the space limited, thus I can't provide complete details of every feature. I have provided links to help you get more information. And as ever, Bing and Google are your friends.
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image