Book Image

Windows Server Automation with PowerShell Cookbook - Fourth Edition

By : Thomas Lee
Book Image

Windows Server Automation with PowerShell Cookbook - Fourth Edition

By: Thomas Lee

Overview of this book

With a foreword from PowerShell creator Jeffrey Snover, this heavily updated edition is designed to help you learn how to use PowerShell 7.1 effectively and manage the core roles, features, and services of Windows Server in an enterprise setting. All scripts are compatible with both Window Server 2022 and 2019. This latest edition equips you with over 100 recipes you'll need in day-to-day work, covering a wide range of fundamental and more advanced use cases. We look at how to install and configure PowerShell 7.1, along with useful new features and optimizations, and how the PowerShell compatibility solution bridges the gap to older versions of PowerShell. Topics include using PowerShell to manage networking and DHCP in Windows Server, objects in Active Directory, Hyper-V, and Azure. Debugging is crucial, so the book shows you how to use some powerful tools to diagnose and resolve issues with Windows Server.
Table of Contents (18 chapters)
Other Books You May Enjoy

Implementing permanent WMI eventing

In the Managing WMI events recipe, you used PowerShell's WMI event handling capability and used temporary event handling. The event handlers were active only as long as the PowerShell session was active and a user was logged in to the host. In that recipe, you created an event subscription and handled the events as your system generated them. This temporary event handling is a great troubleshooting tool that works well as long as you are logged in and are running PowerShell.

WMI also provides permanent event handling. You configure WMI to subscribe and handle events as they occur without using an active and open session. With permanent event handling, you configure WMI to subscribe to a specific event, for instance, adding a new member to a high-privilege AD group such as Enterprise Admins. You can also configure WMI to perform a predefined action when that event occurs, such as creating a report or sending an email message to report on...