33,59 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 610
Veröffentlichungsjahr: 2023
Windows Server Automation with PowerShell Cookbook
Fifth Edition
Powerful ways to automate, manage, and administrate Windows Server 2022 using PowerShell 7.2
Thomas Lee
BIRMINGHAM—MUMBAI
Windows Server Automation with PowerShell Cookbook
Fifth Edition
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Senior Publishing Product Manager: Aaron Tanna
Acquisition Editor – Peer Reviews: Gaurav Gavas
Project Editor: Meenakshi Vijay
Content Development Editor: Liam Draper
Copy Editor: Safis Editing
Technical Editor: Karan Sonawane
Proofreader: Safis Editing
Indexer: Subalakshmi Govindhan
Presentation Designer: Rajesh Shirsath
Developer Relations Marketing Executive: Meghal Patel
First published: March 2013
Second edition: September 2017
Third edition: February 2019
Fourth edition: July 2021
Fifth edition: January 2023
Production reference: 1270123
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80461-423-5
www.packt.com
Thomas Lee is a consultant, trainer, and writer from England and has been in the IT business since the late 1960s. After graduating from Carnegie Mellon University, Thomas joined ComShare, where he was a systems programmer building the Commander II time-sharing operating system, a forerunner of today’s cloud computing paradigm. In the mid 1970s, he moved to ICL to work on the VME/K operating system. After a sabbatical in 1980 and 1981, he joined what is today known as Accenture, leaving in 1988 to run his own consulting and training business, which is still active today.
Thomas worked for Microsoft in Redmond to develop both multiple Microsoft official training courses and several chapters on DNS for the Windows Server 2003 Resource kit. Later, Thomas also worked for both QA (as Chief Technologist), and for Global Knowledge as Chief Architect. In both roles, he developed and delivered training for a variety of customers, including Microsoft.
Today, Thomas writes, trains, and consults. He is a site moderator and PowerShell group administrator at the popular SpiceWorks.com site. He is responsible for and a major contributor to the Microsoft PowerShell Community blog (https://devblogs.microsoft.com/powershell-community/).
Thomas holds numerous Microsoft certifications, including MCSE (one of the first in the world) and later versions, MCT (25 years), and has been awarded Microsoft’s MVP award 17 times. Over the years, he has written and contributed to a variety of books on Windows and TCP/IP.
He lives today in a cottage in the English countryside with his family, a nice wine cellar, and a huge collection of live recordings by The Grateful Dead and The Jerry Garcia Band.
Mike Roberts is a PowerShell ninja not only in his profession, but also teaches it on his blog: https://gngr.ninja. Through his blog, he hopes to inspire others by showing them what different technologies are capable of.
I am eternally grateful for the support of my family, and Destiny. Thank you!
Join our community’s Discord space for discussions with the author and other readers:
https://packt.link/SecNet
Preface
Who this book is for
What this book covers
To get the most out of this book
Get in touch
Installing and Configuring PowerShell 7
Introduction
Systems used in the chapter
Installing PowerShell 7
Getting ready
How to do it...
How it works...
There’s more...
Installing PowerShell 7 Using Chocolatey
Getting ready
How to do it...
How it works...
There’s more...
Using the PowerShell 7 Console
Getting ready
How to do it...
How it works...
There’s more...
Building PowerShell 7 Profile Files
Getting ready
How to do it...
How it works...
There’s more...
Exploring Installation Artifacts
Getting ready
How to do it...
How it works...
There’s more...
Installing VS Code
Getting ready
How to do it...
How it works...
There’s more...
Installing the Cascadia Code Font
How to do it...
How it works...
There’s more...
Exploring PSReadLine
How to do it...
How it works...
There’s more...
Managing PowerShell 7 in the Enterprise
Introduction
The system used in the chapter
Utilizing Windows PowerShell Compatibility
Getting ready
How to do it...
How it works...
There’s more...
Installing RSAT
Getting ready
How to do it...
How it works...
There’s more...
Exploring Package Management
Getting ready
How to do it...
How it works...
There’s more...
Exploring PowerShellGet and the PS Gallery
Getting ready
How to do it...
How it works...
There’s more...
Creating and Using a Local Package Repository
Getting ready
How to do it...
How it works...
There’s more...
Establishing a Script Signing Environment
Getting ready
How to do it...
How it works...
There’s more...
Working With Shortcuts and the PSShortCut Module
Getting ready
How to do it...
How it works...
There’s more...
Working With Archive Files
Getting ready
How to do it...
How it works...
There’s more...
Searching for Files Using the Everything Search Tool
Getting ready
How to do it...
How it works...
There’s more...
Exploring .NET
Introduction
The system used in the chapter
Exploring .NET Assemblies
Getting ready
How to do it...
How it works…
There’s more...
Exploring .NET Classes
Getting ready
How to do it...
How it works...
There’s more...
Exploring .NET Methods
Getting ready
How to do it...
How it works...
There’s more...
Creating a C# Extension
Getting ready
How to do it...
How it works...
There’s more...
Creating a cmdlet
Getting ready
How to do it...
How it works...
There’s more...
Managing Active Directory
Introduction
The systems used in the chapter
Installing a Forest Root Domain
Getting ready
How to do it...
How it works...
There’s more...
Testing an AD installation
Getting ready
How to do it...
How it works...
There’s more...
Installing a Replica Domain Controller
Getting ready
How to do it...
How it works...
There’s more...
Installing a Child Domain
Getting ready
How to do it...
How it works...
There’s more...
Creating and Managing AD Users and Groups
Getting ready
How to do it...
How it works...
There’s more...
Managing AD Computers
Getting ready
How to do it...
How it works...
There’s more...
Adding/Removing Users Using a CSV Files
Getting ready
How to do it...
How it works...
There’s more...
Creating Group Policy Objects
Getting ready
How to do it...
How it works...
There’s more...
Reporting on AD Users
Getting ready
How to do it...
How it works...
There’s more...
Reporting on AD Computers
Getting ready
How to do it...
How it works...
There’s more...
Managing AD Replication
Getting ready
How to do it…
How it works…
There’s more…
Managing Networking
Introduction
The systems used in the chapter
Configuring IP Addressing
Getting ready
How to do it...
How it works...
There’s more...
Testing Network Connectivity
Getting ready
How to do it...
How it works...
There’s more...
Installing DHCP
Getting ready
How to do it...
How it works...
There’s more...
Configuring DHCP Scopes and Options
Getting ready
How to do it...
How it works...
There’s more...
Using DHCP
Getting ready
How to do it...
How it works...
There’s more...
Configuring a DHCP Reservation
Getting ready
How to do it...
How it works...
There’s more...
Implementing DHCP Fail Over/Load Balancing
Getting ready
How to do it...
How it works...
There’s more...
Implementing DNS in the Enterprise
Getting ready
How to do it...
How it works...
There’s more...
Managing DNS Zones and Resource Records
Getting ready
How to do it...
How it works...
There’s more...
Configuring DNS Forwarding
Getting ready
How to do it...
How it works...
There’s more...
Implementing Enterprise Security
Introduction
The systems used in the chapter
Implementing Just Enough Administration (JEA)
Getting ready
How to do it...
How it works...
There’s more...
Examining Applications and Services Logs
Getting ready
How to do it...
How it works...
There’s more...
Discovering Logon Events in the Event Log
Getting ready
How to do it...
How it works...
There’s more...
Deploying PowerShell Group Policies
Getting ready
How to do it...
How it works...
There’s more...
Using PowerShell Script Block Logging
Getting ready
How to do it...
How it works...
There’s more...
Configuring AD Password Policies
Getting ready
How to do it...
How it works...
There’s more...
Managing Windows Defender Antivirus
Getting ready
How to do it...
How it works...
There’s more...
Managing Storage
Introduction
The systems used in the chapter
Managing Disks
Getting ready
How to do it...
How it works...
There’s more...
Managing File Systems
Getting ready
How to do it...
How it works...
There’s more...
Exploring PowerShell Providers and the FileSystem Provider
Getting ready
How to do it...
How it works...
There’s more...
Managing Storage Replica
Getting ready
How to do it...
How it works...
There’s more...
Deploying Storage Spaces
Getting ready
How to do it...
How it works...
There’s more...
Managing Shared Data
Introduction
The systems used in the chapter
Managing NTFS File and Folder Permissions
Getting ready
How to do it...
How it works...
There’s more...
Securing Your SMB File Server
Getting ready
How to do it...
How it works...
There’s more...
Creating and Securing SMB Shares
Getting ready
How to do it...
How it works...
There’s more...
Accessing SMB Shares
Getting ready
How to do it...
How it works...
There’s more...
Creating an iSCSI Target
Getting ready
How to do it...
How it works...
There’s more...
Using an iSCSI Target
Getting ready
How to do it...
How it works...
There’s more...
Implementing FSRM Filestore Quotas
Getting ready
How to do it...
How it works...
There’s more...
Implementing FSRM Filestore Reporting
Getting ready
How to do it...
How it works...
There’s more...
Implementing FSRM Filestore Screening
Getting ready
How to do it...
How it works...
There’s more...
Managing Printing
Introduction
The systems used in the chapter
Installing and Sharing Printers
Getting ready
How to do it...
How it works...
There’s more...
Publishing a Printer to Active Directory
Getting ready
How to do it...
How it works...
There’s more...
Changing the Spooler Directory
Getting ready
How to do it...
How it works...
There’s more...
Changing Printer Drivers
Getting ready
How to do it...
How it works...
Printing a Test Page
Getting ready
How to do it...
How it works...
There’s more...
Managing Printer Security
Getting ready
How to do it...
How it works...
There’s more...
Creating a Printer Pool
Getting ready
How to do it…
How it works...
There’s more...
Exploring Windows Containers
Introduction
The systems used in the chapter
Configuring a container host
Getting ready
How to do it...
How it works...
There’s more...
Deploying sample containers
Getting ready
How to do it...
How it works...
There’s more...
Deploying IIS in a container
Getting ready
How to do it…
How it works...
There’s more...
Using a Dockerfile to create a custom container
Getting ready
How to do it...
How it works...
There’s more...
Managing Hyper-V
Introduction
The systems used in the chapter
Installing Hyper-V inside Windows Server
Getting ready
How to do it...
How it works...
There’s more…
See also
Creating a Hyper-V VM
Getting ready
How to do it...
How it works...
There’s more...
Using PowerShell Direct
Getting ready
How to do it...
How it works...
There’s more...
Using Hyper-V VM groups
Getting ready
How to do it...
How it works...
There’s more...
Configuring the VM hardware
Getting ready
How to do it...
How it works...
There’s more...
Configuring VM networking
Getting ready
How to do it...
How it works...
There’s more...
Implementing nested virtualization
Getting ready
How to do it...
How it works...
There’s more...
Managing the VM state
Getting ready
How to do it...
How it works...
There’s more...
Managing a VM and VM storage movement
Getting ready
How to do it...
How it works...
There’s more...
Managing VM replication
Getting ready
How to do it...
How it works...
There’s more...
Managing VM checkpoints
Getting ready
How to do it...
How it works...
There’s more...
Creating a Hyper-V report
Getting ready
How to do it...
How it works...
There’s more...
Debugging and Troubleshooting Windows Server
Introduction
The systems used in the chapter
Using PSScriptAnalyzer
Getting ready
How to do it...
How it works...
There’s more...
Performing BASIC Network Troubleshooting
Getting ready
How to do it...
How it works...
There’s more...
Using Get-NetView to Diagnose Network Issues
Getting ready
How to do it...
How it works...
There’s more...
Using Best Practices Analyzer
Getting ready
How to do it...
How it works...
There’s more...
Exploring PowerShell Script Debugging
Getting ready
How to do it...
How it works...
There’s more...
Managing Windows Server with Window Management Instrumentation (WMI)
Introduction
WMI architecture
The systems used in the chapter
Exploring WMI Architecture in Windows
Getting ready
How to do it...
How it works...
There’s more...
Exploring WMI Namespaces
Getting ready
How to do it...
How it works...
There’s more...
Exploring WMI Classes
Getting ready
How to do it...
How it works...
There’s more...
Obtaining WMI Class Instances
Getting ready
How to do it...
How it works...
There’s more...
Using WMI Methods
Getting ready
How to do it...
How it works...
There’s more...
Using WMI Events
Getting ready
How to do it...
How it works...
There’s more...
Implementing Permanent WMI Eventing
Getting ready
How to do it...
How it works...
There’s more...
Managing Windows Update Services
Introduction
The systems used in the chapter
Installing Windows Server Update Services
Getting ready
How to do it...
How it works...
There’s more...
Configuring WSUS Update Synchronization
Getting ready
How to do it...
How it works...
There’s more...
Configuring the Windows Update Client
Getting ready
How to do it...
How it works...
There’s more...
Creating Computer Target Groups
Getting ready
How to do it...
How it works...
There’s more...
Configuring WSUS Automatic Approvals
Getting ready
How to do it...
How it works...
There’s more...
Managing WSUS Updates
Getting ready
How to do it...
How it works...
There’s more...
Other Books You May Enjoy
Index
Cover
Index
Once you’ve read Windows Server Automation with PowerShell Cookbook, Fifth Edition, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere?Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link belowhttps://packt.link/free-ebook/9781804614235
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directly