0%

Over 100 PowerShell recipes for working more effectively with Windows Server 2022/2019

Key Features

  • Develop a holistic understanding of Windows Server 2022/2019 with PowerShell 7.1
  • Learn best practices for PowerShell scripting to automate common tasks and manage AD, enterprise security, WMI, Azure, and .NET 5
  • Discover new ways to optimize your PowerShell code by working through easy-to-follow recipes

Book Description

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 2022/2019 in an enterprise setting. Brand new to this edition are recipes exploring the .NET Framework, enterprise server security, and managing Windows Server with Windows Management Instrumentation (WMI).

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.

What you will learn

  • Perform key admin tasks on Windows Server 2022/2019
  • Keep your organization secure with JEA, group policies, logs, and Windows Defender
  • Use the .NET Framework for administrative scripting
  • Manage data and storage on Windows, including disks, volumes, and filesystems
  • Create and configure Hyper-V VMs, implementing storage replication and checkpoints
  • Set up virtual machines, websites, and shared files on Azure
  • 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

Who this book is for

This book is for systems administrators, software architects, developers, or engineers working with Windows Server 2022/2019 seeking to automate tasks more effectively with PowerShell 7.1. Basic knowledge of PowerShell is expected.

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
    2. Installing PowerShell 7
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Using the PowerShell 7 console
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Exploring PowerShell 7 installation artifacts
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Building PowerShell 7 profile files
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Installing VS Code
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
    27. Installing the Cascadia Code font
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
    32. Exploring PSReadLine
    33. Getting ready
    34. How to do it...
    35. How it works...
    36. There's more...
  3. Introducing PowerShell 7
    1. Introduction
    2. Exploring new operators
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Exploring parallel processing with ForEach-Object
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Improvements in ForEach and ForEach-Object
    13. Getting ready
    14. How to do it...
    15. How it works…
    16. There's more...
    17. Improvements in Test-Connection
    18. Getting ready
    19. How to do it...
    20. How it works…
    21. There's more...
    22. Using Select-String
    23. Getting ready
    24. How to do it...
    25. How it works…
    26. There's more...
    27. Exploring the error view and Get-Error
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
    32. Exploring experimental features
    33. Getting ready
    34. How to do it...
    35. How it works...
    36. There's more...
  4. Exploring Compatibility with Windows PowerShell
    1. Introduction
    2. Module compatibility
    3. Incompatible modules
    4. Exploring compatibility with Windows PowerShell
    5. Getting ready
    6. How to do it...
    7. How it works...
    8. There's more...
    9. Using the Windows PowerShell compatibility solution
    10. Getting ready
    11. How to do it…
    12. How it works...
    13. There's more...
    14. Exploring compatibility solution limitations
    15. Getting ready
    16. How to do it...
    17. How it works...
    18. There's more...
    19. Exploring the module deny list
    20. Getting ready
    21. How to do it...
    22. How it works...
    23. There's more...
    24. Importing format XML
    25. Getting ready
    26. How to do it...
    27. How it works...
    28. There's more...
    29. Leveraging compatibility
    30. Getting ready
    31. How to do it...
    32. How it works...
    33. There's more...
  5. Using PowerShell 7 in the Enterprise
    1. Introduction
    2. Installing RSAT tools on Windows Server
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Exploring package management
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Exploring PowerShellGet and the PS Gallery
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Creating a local PowerShell repository
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Establishing a script signing environment
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
    27. Working with shortcuts and the PSShortcut module
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
    32. Working with archive files
    33. Getting ready
    34. How to do it...
    35. How it works...
    36. There's more...
  6. Exploring .NET
    1. Introduction
    2. Exploring .NET assemblies
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Examining .NET classes
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Leveraging .NET methods
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Creating a C# extension
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Creating a PowerShell cmdlet
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
  7. Managing Active Directory
    1. Introduction
    2. Systems used in this chapter
    3. Installing an AD forest root domain
    4. Getting ready
    5. How to do it...
    6. How it works...
    7. There's more...
    8. Testing an AD installation
    9. Getting ready
    10. How to do it...
    11. How it works...
    12. There's more…
    13. Installing a replica domain controller
    14. Getting ready
    15. How to do it...
    16. How it works...
    17. There's more...
    18. Installing a child domain
    19. Getting ready
    20. How to do it...
    21. How it works...
    22. There's more...
    23. Creating and managing AD users and groups
    24. Getting ready
    25. How to do it...
    26. How it works...
    27. There's more...
    28. Managing AD computers
    29. Getting ready
    30. How to do it...
    31. How it works...
    32. There's more...
    33. Adding users to AD using a CSV file
    34. Getting ready
    35. How to do it...
    36. How it works...
    37. There's more...
    38. Creating Group Policy objects
    39. Getting ready
    40. How to do it...
    41. How it works...
    42. There's more...
    43. Reporting on AD replication
    44. Getting ready
    45. How to do it...
    46. How it works...
    47. There's more...
    48. Reporting on AD computers
    49. Getting ready
    50. How to do it...
    51. How it works...
    52. There's more...
    53. Reporting on AD users
    54. Getting ready
    55. How to do it...
    56. How it works...
    57. There's more...
  8. Managing Networking in the Enterprise
    1. Introduction
    2. Configuring IP addressing
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Testing network connectivity
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Installing DHCP
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Configuring DHCP scopes and options
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Using DHCP
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
    27. Implementing DHCP failover and load balancing
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
    32. Deploying DNS in the Enterprise
    33. Getting ready
    34. How to do it...
    35. How it works...
    36. There's more...
    37. Configuring DNS forwarding
    38. Getting ready
    39. How to do it...
    40. How it works...
    41. There's more...
    42. Managing DNS zones and resource records
    43. Getting ready
    44. How to do it...
    45. How it works...
    46. There's more...
  9. Implementing Enterprise Security
    1. Introduction
    2. Implementing Just Enough Administration (JEA)
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Examining Applications and Services Logs
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Discovering logon events in the event log
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Deploying PowerShell group policies
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Using PowerShell Script Block Logging
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
    27. Configuring AD password policies
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
    32. Managing Windows Defender Antivirus
    33. Getting ready
    34. How to do it...
    35. How it works...
    36. There's more...
  10. Managing Storage
    1. Introduction
    2. Managing physical disks and volumes
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Managing filesystems
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Exploring providers and the FileSystem provider
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Managing Storage Replica
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Deploying Storage Spaces
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
  11. Managing Shared Data
    1. Introduction
    2. Managing NTFS file and folder permissions
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Setting up and securing an SMB file server
    8. Getting ready
    9. How to do it…
    10. How it works…
    11. There's more...
    12. Creating and securing SMB shares
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Accessing SMB shares
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Creating an iSCSI target
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
    27. Using an iSCSI target
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
    32. Implementing FSRM quotas
    33. Getting ready
    34. How to do it...
    35. How it works...
    36. There's more...
    37. Implementing FSRM reporting
    38. Getting ready
    39. How to do it...
    40. How it works...
    41. There's more...
    42. Implementing FSRM file screening
    43. Getting ready
    44. How to do it...
    45. How it works...
    46. There's more...
  12. Managing Printing
    1. Introduction
    2. Installing and sharing printers
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Publishing a printer
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Changing the spooler directory
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Changing printer drivers
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more…
    22. Printing a test page
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
    27. Managing printer security
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
    32. Creating a printer pool
    33. Getting ready
    34. How to do it...
    35. How it works...
    36. There's more...
  13. Managing Hyper-V
    1. Introduction
    2. Installing Hyper-V inside Windows Server
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. See also
    8. Creating a Hyper-V VM
    9. Getting ready
    10. How to do it...
    11. How it works...
    12. There's more...
    13. Using PowerShell Direct
    14. Getting ready
    15. How to do it...
    16. How it works...
    17. There's more...
    18. Using Hyper-V VM groups
    19. Getting ready
    20. How to do it...
    21. How it works...
    22. There's more...
    23. Configuring VM hardware
    24. Getting ready
    25. How to do it...
    26. How it works...
    27. There's more...
    28. Configuring VM networking
    29. Getting ready
    30. How to do it...
    31. How it works...
    32. There's more...
    33. Implementing nested virtualization
    34. Getting ready
    35. How to do it...
    36. How it works...
    37. There's more...
    38. Managing VM state
    39. Getting ready
    40. How to do it...
    41. How it works...
    42. There's more...
    43. Managing VM and storage movement
    44. Getting ready
    45. How to do it...
    46. How it works...
    47. There's more...
    48. Managing VM replication
    49. Getting ready
    50. How to do it...
    51. How it works...
    52. There's more...
    53. Managing VM checkpoints
    54. Getting ready
    55. How to do it...
    56. How it works...
    57. There's more...
  14. Managing Azure
    1. Introduction
    2. Getting started using Azure with PowerShell
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Creating Azure resources
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Exploring the Azure storage account
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Creating an Azure SMB file share
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Creating an Azure website
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
    27. Creating an Azure Virtual Machine
    28. Getting ready
    29. How to do it...
    30. How it works...
    31. There's more...
  15. Troubleshooting with PowerShell
    1. Introduction
    2. Using PowerShell Script Analyzer
    3. Getting ready
    4. How to do it...
    5. How it works...
    6. There's more...
    7. Using Best Practices Analyzer
    8. Getting ready
    9. How to do it...
    10. How it works...
    11. There's more...
    12. Network troubleshooting
    13. Getting ready
    14. How to do it...
    15. How it works...
    16. There's more...
    17. Checking network connectivity using Get-NetView
    18. Getting ready
    19. How to do it...
    20. How it works...
    21. There's more...
    22. Exploring PowerShell script debugging
    23. Getting ready
    24. How to do it...
    25. How it works...
    26. There's more...
  16. Managing with Windows Management Instrumentation
    1. Introduction
    2. WMI architecture
    3. Exploring WMI in Windows
    4. Getting ready
    5. How to do it...
    6. How it works...
    7. There's more...
    8. Exploring WMI namespaces
    9. Getting ready
    10. How to do it...
    11. How it works...
    12. There's more...
    13. Exploring WMI classes
    14. Getting ready
    15. How to do it...
    16. How it works...
    17. There's more...
    18. Obtaining local and remote WMI objects
    19. Getting ready
    20. How to do it...
    21. How it works...
    22. There's more...
    23. Using WMI methods
    24. Getting ready
    25. How to do it...
    26. How it works...
    27. There's more...
    28. Managing WMI events
    29. Getting ready
    30. How to do it...
    31. How it works...
    32. There's more...
    33. Implementing permanent WMI eventing
    34. Getting ready
    35. How to do it...
    36. How it works...
    37. There's more...
  17. Other Books You May Enjoy
  18. Index
3.17.6.75