Book Image

Windows Server Automation with PowerShell Cookbook - Fifth Edition

By : Thomas Lee
Book Image

Windows Server Automation with PowerShell Cookbook - Fifth Edition

By: Thomas Lee

Overview of this book

The Windows Server Automation with PowerShell Cookbook is back with a new edition, featuring over 100 PowerShell recipes that will make your day-to-day work easier. This book is designed to help you learn how to install, configure and use PowerShell 7.2 effectively. To start with, we’ll look at how to install and configure PowerShell 7.2, along with useful new features and optimizations, and show you how the PowerShell compatibility solution bridges the gap to older versions of PowerShell. We’ll also be covering a wide range of fundamental and more advanced use cases, including how to create a VM and set up an Azure VPN, as well as looking at how to back up to Azure. As you progress, you’ll explore topics such as using PowerShell to manage networking and DHCP in Windows Server, objects in Active Directory, Hyper-V, and Azure. We’ll also take a closer look at WSUS, containers and see how to handle modules that are not directly compatible with PowerShell 7. Finally, you’ll also learn how to use some powerful tools to diagnose and resolve issues with Windows Server. By the end of this PowerShell book, you’ll know how to use PowerShell 7.2 to automate tasks on Windows Server 2022 with ease, helping your Windows environment to run faster and smoother.
Table of Contents (17 chapters)
15
Other Books You May Enjoy
16
Index

What this book covers

Chapter 1, Installing and Configuring PowerShell 7, shows you how you can install and configure both PowerShell 7 and VS Code, which replaces the Windows PowerShell Integrated Scripting Environment (ISE) as well as installing a new font, Cascadia Code. This chapter also examines the PowerShell 7 environment, including examining the PSReadLine module.

Chapter 2, Managing PowerShell 7 in the Enterprise, looks at how you can use various PowerShell 7 features that might be more common within larger enterprises. These include the Remote Server Administration Tools (RSAT), package management and the PowerShell Gallery, and creating a local module repository. The chapter also looks at PowerShell script signing, using short cuts, and working with archive (.zip) files.

Chapter 3, Exploring .NET, examines .NET, which provides the foundation for PowerShell 7. The chapter looks at .NET assemblies, classes, and methods. The chapter concludes with showing you how to create simple C#-based PowerShell extensions, as well as a full PowerShell cmdlet.

Chapter 4, Managing Active Directory, examines how to install, manage, and leverage Active Directory, including installing domains and child domains, managing AD objects, and leveraging Group Policy. This chapter also shows how you can use a CSV to create multiple AD user accounts.

Chapter 5, Managing Networking, shows you how to manage Windows networking with PowerShell. Networks are today central to almost every organization and this chapter looks at a variety of network-related tasks, including looking at new ways (with PowerShell) to do old things, such as setting up DNS, DHCP, and DHCP failover and load balancing.

Chapter 6, Implementing Enterprise Security, looks at security aspects within the context of an enterprise environment. The chapter looks at Just Enough Administration (JEA), which limits the actions an administrator can perform remotely). The chapter also looks at the event log, and PowerShell 7’s script block logging, setting PowerShell 7 related Group policies and configuring a fine-grained AD password policy. The chapter concludes by looking at the Windows Defender AV product built into Windows Server.

Chapter 7, Managing Storage, looks at managing storage in Windows Server, including locally attached devices and Windows Storage Spaces. The chapter also looks at managing Storage Replica, a feature of Windows Server 2022.

Chapter 8, Managing Shared Data, examines different ways to share data and manage your shared data with Windows Server and PowerShell, including managing NTFS permissions, creating and securing SMB shares, and setting up and using iSCSI. The chapter concludes by looking at File Server Resource Manager (FSRM), a feature of Windows Server, and managing FSRM quotas, file screening, and reporting.

Chapter 9, Managing Printing, shows you how to manage printers, printer queues, and printer drivers as well as how to set up a printer pool. You will also examine how to print a test page.

Chapter 10, Exploring Windows Containers, shows you how to install the Containers feature in Windows Server 2022, and use sample containers you can download. You can use containers to create a website and create a custom container using a Docker file.

Chapter 11, Managing Hyper-V, demonstrates the use of Hyper-V. This chapter shows you how to build and deploy VMs with Hyper-V. This includes nested Hyper-V running a Hyper-V VM inside another Hyper-V VM, which is useful in many scenarios.

Chapter 12, Debugging and Troubleshooting Windows Server, looks at a number of aspects of both reactive and proactive troubleshooting. This includes using the PowerShell script debugger, getting events from the event log, and using the Best Practice Analyzer contained in Windows Server.

Chapter 13, Managing Window Server with Window Management Instrumentation (WMI), examines WMI and enables you to investigate WMI namespaces, classes, and class occurrences. You retrieve information from WMI classes, update WMI using WMI methods, and manage WMI events, including WMI permanent eventing.

Chapter 14, Managing Windows Update Services, examines how you can install, configure, and manage the Windows Server Update Service (WSUS). This chapter shows how to manage a Windows feature that has no PowerShell 7 commands and does not work natively in PowerShell 7.