Windows Server Automation with PowerShell Cookbook - Fifth Edition

Book description

Use over 100 PowerShell 7.2 recipes to deepen your understanding of Windows Server 2022 and see how to automate common administrative tasks with ease

Purchase of the print or Kindle book includes a free eBook in PDF format

Key Features

  • New edition updated to the latest version of PowerShell 7.2 and Windows Server 2022
  • Discover new ways to optimize your PowerShell code by working through easy-to-follow recipes
  • Learn PowerShell best practices to automate common tasks and manage DHCP in Microsoft Windows Server, objects in Active Directory, Hyper-V, and Azure

Book Description

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.

What you will learn

  • Perform key admin tasks on Windows Server
  • Keep your organization secure with JEA, group policies, logs, and Windows Defender
  • Use .NET Framework for administrative scripting
  • Manage data and storage on Windows, including disks, volumes, and filesystems
  • Report system performance using built-in cmdlets and WMI to obtain single measurements
  • Apply the right tools and modules to troubleshoot and debug Windows Server
  • Create, manage, and back up a second VM using the subnetwork in Azure
  • Learn how to set up a VPN in Azure with PowerShell

Who this book is for

This book is for systems administrators, software architects, developers, consultants, and engineers working with Windows Server 2022 who want to automate tasks more effectively with PowerShell 7.2. You'll need to have conquered the basics of PowerShell and have a rudimentary understanding of PowerShell scripting before you can get started with this book.

Table of contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Get in touch
  2. Installing and Configuring PowerShell 7
    1. Introduction
      1. Systems used in the chapter
    2. Installing PowerShell 7
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Installing PowerShell 7 Using Chocolatey
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Using the PowerShell 7 Console
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Building PowerShell 7 Profile Files
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Exploring Installation Artifacts
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Installing VS Code
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Installing the Cascadia Code Font
      1. How to do it...
      2. How it works...
      3. There’s more...
    9. Exploring PSReadLine
      1. How to do it...
      2. How it works...
      3. There’s more...
  3. Managing PowerShell 7 in the Enterprise
    1. Introduction
      1. The system used in the chapter
    2. Utilizing Windows PowerShell Compatibility
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Installing RSAT
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Exploring Package Management
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Exploring PowerShellGet and the PS Gallery
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Creating and Using a Local Package Repository
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Establishing a Script Signing Environment
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Working With Shortcuts and the PSShortCut Module
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    9. Working With Archive Files
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    10. Searching for Files Using the Everything Search Tool
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  4. Exploring .NET
    1. Introduction
      1. The system used in the chapter
    2. Exploring .NET Assemblies
      1. Getting ready
      2. How to do it...
      3. How it works…
      4. There’s more...
    3. Exploring .NET Classes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Exploring .NET Methods
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Creating a C# Extension
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Creating a cmdlet
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  5. Managing Active Directory
    1. Introduction
      1. The systems used in the chapter
    2. Installing a Forest Root Domain
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Testing an AD installation
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Installing a Replica Domain Controller
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Installing a Child Domain
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Creating and Managing AD Users and Groups
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Managing AD Computers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Adding/Removing Users Using a CSV Files
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    9. Creating Group Policy Objects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    10. Reporting on AD Users
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    11. Reporting on AD Computers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    12. Managing AD Replication
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  6. Managing Networking
    1. Introduction
      1. The systems used in the chapter
    2. Configuring IP Addressing
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Testing Network Connectivity
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Installing DHCP
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Configuring DHCP Scopes and Options
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Using DHCP
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Configuring a DHCP Reservation
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Implementing DHCP Fail Over/Load Balancing
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    9. Implementing DNS in the Enterprise
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    10. Managing DNS Zones and Resource Records
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    11. Configuring DNS Forwarding
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  7. Implementing Enterprise Security
    1. Introduction
      1. The systems used in the chapter
    2. Implementing Just Enough Administration (JEA)
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Examining Applications and Services Logs
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Discovering Logon Events in the Event Log
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Deploying PowerShell Group Policies
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Using PowerShell Script Block Logging
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Configuring AD Password Policies
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Managing Windows Defender Antivirus
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  8. Managing Storage
    1. Introduction
      1. The systems used in the chapter
    2. Managing Disks
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Managing File Systems
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Exploring PowerShell Providers and the FileSystem Provider
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Managing Storage Replica
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Deploying Storage Spaces
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  9. Managing Shared Data
    1. Introduction
      1. The systems used in the chapter
    2. Managing NTFS File and Folder Permissions
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Securing Your SMB File Server
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Creating and Securing SMB Shares
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Accessing SMB Shares
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Creating an iSCSI Target
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Using an iSCSI Target
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Implementing FSRM Filestore Quotas
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    9. Implementing FSRM Filestore Reporting
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    10. Implementing FSRM Filestore Screening
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  10. Managing Printing
    1. Introduction
      1. The systems used in the chapter
    2. Installing and Sharing Printers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Publishing a Printer to Active Directory
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Changing the Spooler Directory
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Changing Printer Drivers
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Printing a Test Page
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Managing Printer Security
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Creating a Printer Pool
      1. Getting ready
      2. How to do it…
      3. How it works...
      4. There’s more...
  11. Exploring Windows Containers
    1. Introduction
      1. The systems used in the chapter
    2. Configuring a container host
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Deploying sample containers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Deploying IIS in a container
      1. Getting ready
      2. How to do it…
      3. How it works...
      4. There’s more...
    5. Using a Dockerfile to create a custom container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  12. Managing Hyper-V
    1. Introduction
      1. The systems used in the chapter
    2. Installing Hyper-V inside Windows Server
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more…
      5. See also
    3. Creating a Hyper-V VM
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Using PowerShell Direct
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Using Hyper-V VM groups
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Configuring the VM hardware
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Configuring VM networking
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Implementing nested virtualization
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    9. Managing the VM state
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    10. Managing a VM and VM storage movement
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    11. Managing VM replication
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    12. Managing VM checkpoints
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    13. Creating a Hyper-V report
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  13. Debugging and Troubleshooting Windows Server
    1. Introduction
      1. The systems used in the chapter
    2. Using PSScriptAnalyzer
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Performing BASIC Network Troubleshooting
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Using Get-NetView to Diagnose Network Issues
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Using Best Practices Analyzer
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Exploring PowerShell Script Debugging
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  14. Managing Windows Server with Window Management Instrumentation (WMI)
    1. Introduction
      1. WMI architecture
      2. The systems used in the chapter
    2. Exploring WMI Architecture in Windows
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Exploring WMI Namespaces
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Exploring WMI Classes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Obtaining WMI Class Instances
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Using WMI Methods
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Using WMI Events
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    8. Implementing Permanent WMI Eventing
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  15. Managing Windows Update Services
    1. Introduction
      1. The systems used in the chapter
    2. Installing Windows Server Update Services
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Configuring WSUS Update Synchronization
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    4. Configuring the Windows Update Client
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    5. Creating Computer Target Groups
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    6. Configuring WSUS Automatic Approvals
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    7. Managing WSUS Updates
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
  16. Other Books You May Enjoy
  17. Index

Product information

  • Title: Windows Server Automation with PowerShell Cookbook - Fifth Edition
  • Author(s): Thomas Lee
  • Release date: January 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781804614235