
PowerShell 7 for IT Professionals
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
PowerShell 7 for IT Pros is your guide to using PowerShell 7, the open source, cross-platform version of Windows PowerShell. Windows IT professionals can begin setting up automation in PowerShell 7, which features many improvements over the early version of PowerShell Core and Windows PowerShell. PowerShell 7 users can enjoy the high level of compatibility with the Windows PowerShell modules they rely on today. This book shows IT professionals--especially Windows administrators and developers--how to use PowerShell7 to engage in their most important tasks, such as managing networking, using AD/DNS/DHCP, leveraging Azure, and more.
To make it easy to learn everything PowerShell 7 has to offer, this book includes robust examples, each containing sample code so readers can follow along. Scripts are based on PowerShell 7 running on Windows 10 19H1 or later and Windows Server 2019.
* Learn to navigate the PowerShell 7 administrative environment
* Use PowerShell 7 to automate networking, Active Directory, Windows storage, shared data, and more
* Run Windows Update, IIS, Hyper-V, and WMI and CIM cmdlets within PowerShell 7
* Understand how to handle reporting in the new PowerShell 7 environment
PowerShell 7 for IT Pros provides exclusive coverage of using PowerShell with both cloud-based systems and virtualized environments (Hyper V and Azure). Written by PowerShell veteran Thomas Lee, this is the only book you'll need to get started with PowerShell 7.
More details
Other editions
Additional editions

Person
Content
Introduction xxxiii
Chapter 1 Setting Up a PowerShell 7 Environment 1
What is New in PowerShell 7 2
Systems Used in This Book and Chapter 3
Installing PowerShell 7 5
Installing and Configuring VS Code 14
Using the PowerShell Gallery 21
Creating a Local PowerShellGet Repository 24
Creating a Code-Signing Environment 30
Summary 35
Chapter 2 PowerShell 7 Compatibility with Windows PowerShell 37
Examining PowerShell Modules 38
Introducing the Compatibility Solution 48
Things That Do Not Work with PowerShell 7 51
Summary 54
Chapter 3 Managing Active Directory 55
Systems Used in This Chapter 58
Establishing a Forest Root Domain 60
Installing a Replica DC 66
Installing a Child Domain 70
Configuring a Cross-Forest Trust 75
Managing AD Users, Computers, and OUs 86
Adding Users to AD via a CSV 96
Configuring Just Enough Administration (JEA) 100
Summary 109
Chapter 4 Managing Networking 111
Systems Used in This Chapter 112
Configuring IP Addressing 113
Testing Network Connectivity 117
Installing the DHCP Service 121
Configuring DHCP Scopes 124
Configuring DHCP Failover 128
Configuring the DNS Service 133
Configuring DNS Zones and Resource Records 138
Summary 144
Chapter 5 Managing Storage 145
Systems Used in This Chapter 146
Managing Disks and Volumes 147
Managing NTFS Permissions 154
Managing Storage Replica 163
Managing Filestore Quotas 175
Managing File Screening 183
Summary 190
Chapter 6 Managing Shared Data 191
Systems Used in This Chapter 193
Setting Up and Securing an SMB File Server 194
Creating and Securing SMB Shares 198
Creating and Using an iSCSI Target 207
Setting Up a Clustered Scale-Out File Server 218
Summary 229
Chapter 7 Managing Printing 231
Systems Used in This Chapter 232
Installing and Sharing Printers 233
Publishing a Printer in AD 238
Changing the Spool Folder 240
Printing a Test Page 245
Creating a Printer Pool 248
Summary 249
Chapter 8 Managing Hyper-V 251
Systems Used in This Chapter 253
Installing and Configuring Hyper-V 254
Creating a Hyper-V VM 257
Using PowerShell Direct 262
Configuring VM Networking 265
Configuring VM Hardware 271
Implementing Nested Virtualization 277
Using VM Checkpoints 282
Using VM Replication 291
Managing VM Movement 305
Measuring VM Resource Usage 311
Summary 314
Chapter 9 Using WMI with CIM Cmdlets 315
Exploring WMI Namespaces 320
Exploring WMI Classes 328
Getting Local and Remote Objects 330
Invoking WMI Methods 334
Managing WMI Events 339
Implementing Permanent WMI Event Handling 347
Summary 355
Chapter 10 Reporting 357
Systems Used in This Chapter 358
Reporting on AD Users and Computers 359
Managing Filesystem Reporting 365
Collecting Performance Information Using PLA 374
Reporting on PLA Performance Data 379
Creating a Performance Monitoring Graph 382
Creating a System Diagnostics Report 385
Reporting on Printer Usage 387
Creating a Hyper-V Status Report 390
Reviewing Event Logs 395
Summary 402
Index 403
Chapter 1
Setting Up a PowerShell 7 Environment
The first versions of Windows PowerShell were provided via a user-installed download, initially for Windows XP and Windows Server 2008. Today, both Windows Server and Windows 10 come with Windows PowerShell version 5.1-which in this book I'll call simply Windows PowerShell to distinguish it from PowerShell 7 (and the Windows PowerShell Integrated Scripting Environment) installed and available by default. Windows PowerShell comes with a range of commands available for basic administration of Windows.
PowerShell 7 itself does not ship as part of Windows at the time of writing. At some point, the PowerShell team may ship PowerShell 7 as a Windows component, but until that time, you need to download and install it yourself.
The Windows PowerShell Integrated Scripting Environment (ISE) does not support PowerShell 7. IT pros who want a good interactive development environment for PowerShell can use Visual Studio Code (VS Code), a free tool you can also easily download and install. VS Code comes with an array of extensions that provide a much-improved development experience for IT pros (and others).
With earlier versions of PowerShell, the vast majority of commands came bundled into Windows or were added as part of installing an application (such as Exchange Server) or adding a Windows feature to your system. With PowerShell 7, the PowerShell Gallery has become a core source of modules/commands that you can use to perform various administrative tasks. To ensure that you can take advantage of the PowerShell Gallery, you need to be sure that the PowerShellGet module is up to date.
What Is New in PowerShell 7
PowerShell 7 is the latest version of PowerShell. The PowerShell development team released PowerShell 7.0 in March 2020. By the time you read this, the development team is certain to have released newer minor updates. PowerShell 7 has a number of key new features that IT pros can leverage.
If you are familiar with and can use Windows PowerShell to manage your Windows systems, almost all your knowledge is directly transferable to the new environment. Need to get help on a command? Just type Get-Help at the PowerShell command line. The basic architecture of PowerShell remains the same, with many internal changes, significant improvements, and a few breaking issues.
From the perspective of an IT professional with a working knowledge of managing Windows using Windows PowerShell, here are the key changes you can find:
- Redeveloped cmdlets, based on .NET Core and open sourced via GitHub: You can now read and even help to extend any cmdlet in PowerShell 7. This also means that the cmdlets were written to use .NET Core-which has created a few small compatibility issues.
- A robust compatibility layer: You use this to access Windows PowerShell modules that do not directly work on PowerShell 7. This means that all but a small number of Windows PowerShell 5.1 modules are available with and work under PowerShell 7. Chapter 2, "PowerShell 7 Compatibility with Windows PowerShell," describes this compatibility layer in more detail and notes how it works and its limitations as well as providing work-around solutions.
- Significant performance enhancements: In porting the Windows PowerShell modules to PowerShell 7, the development team was able to review the code and deliver performance enhancements. Processing large collections, for example using
Foreach, is now a lot faster. TheForeach-Objectcmdlet now has a-Parallelswitch that allows you to run script blocks in parallel, which can provide substantially shorter run times, especially on larger multiprocessor and multicore servers. - New PowerShell language operators: There are three new operator sets in PowerShell: the Ternary operator (
a ? b : c), the Pipeline chain operators (||and&&), and the Null coalescing operators (??and??=). These operators were implemented in other shells such as Bash or Zsh, and you can now use them in PowerShell 7. - Simplified error views: Windows PowerShell error messages were excellent and contained a lot of information. But in most cases the rich output was more than you normally need. Error messages in PowerShell 7 are now much more succinct. And when you do need that additional information, you can use
Get-Errorto retrieve the full details of any error. You can set the$ErrorViewvariable toNormalViewto view the older Windows PowerShell-style error messages orCategoryViewto see just the error category. - Experimental features: The PowerShell team has implemented a raft of new features that are at an experimental stage. You can opt in (or not) to these features. This gives you the opportunity to try new things and provide feedback.
- Automatic new version notification: At the time of writing, there is no support for PowerShell 7 within the Windows Store or via Windows Update. That means you need to manage the updates yourself, and these messages provide timely notification that a newer version of PowerShell exists for you to download.
Set-Locationnow supports a path of - and +: When you useSet-Locationto reset your current working directory, you can use-Path "-"to instructSet-Locationto move to the last folder. Having moved back, you can set location using + to move forward.- Ability to invoke a DSC resource directly: PowerShell 7 does not support desired state configuration, so no pull/report servers, local configuration manager, and so on. You can, however, manually invoke DSC resources on a given host, which provides a partial solution.
The PowerShell 7 snippets in this book use and demonstrate most of these new features. For more information on any of these features, including use cases and examples, use your favorite search engine as the PowerShell community has produced a significant amount of content that describes the features. You can find numerous higher-level posts, such as the article at https://www.thomasmaurer.ch/2020/03/whats-new-in-powershell-7-check-it-out. There are also more detailed articles that cover specific new features such as tfl09.blogspot.com/2020/03/introduction-and-background-welcome-to.html, for example, which provides details on the new Pipeline Chain and Ternary operators.
Systems Used in This Book and Chapter
This book examines how you can use PowerShell 7 to carry out a wide range of tasks, including setting permissions on a file share, collecting and reporting on performance data, and installing and configuring Active Directory. To demonstrate these and many other tasks, this book uses a set of hosts and two domains: Reskit.Org and Kapoho.Com. You have options as to how you provision these systems.
Server VM Build Scripts
The scripts in this book assume you have a set of servers ready to configure. You could, if you choose, build each computer used in this book based on physical hardware. A simpler alternative is to build the necessary server VMs using Hyper-V using the build scripts you can find at github.com/doctordns/ReskitBuildScripts. This GitHub repository contains a README.MD file (github.com/doctordns/ReskitBuildScripts/blob/master/README.md) that explains how you can use these scripts to build your VM farm.
By way of background, these scripts are used to create VMs for a variety of training courses and other books. You do not need to create all the VMs. In the introduction to each chapter, you discover the specific VMs that the chapter uses.
These build scripts build VMs, but you need to take some care in terms of the order in which you build the VMs, where you store VMs and virtual hard disks, and so on.
The build scripts build VMs with basic networking (one NIC) although you can always add more should you wish. The scripts build the VMs you need for this book using a specific set of network addresses. The document github.com/doctordns/ReskitBuildScripts/blob/master/ReskitNetwork.md shows the details of the network hosts and IP addresses.
VM Internet Access
The VMs (or hosts if you choose to use physical computers) require Internet access. The VMs are all on the 10.10.10.0/24 IPv4 network implemented as an internal Hyper-V network, using an internal Hyper-V virtual switch. There are two broad mechanisms you can use to provide this.
First, you can configure each VM to have a second virtual NIC. You configure this NIC to use an external switch that you bind to your VM host's external NIC. This is a simple solution and can be set up quickly.
Another alternative is to set up a Windows Server VM running Routing and Remote Access. You configure the VM with two NICs (one internal, the other external) and configure routing between the 10.10.10.0/24 subnet used by the VMs in this book and the internet.
Systems in Use for This Chapter
In this chapter, you use PowerShell 7 to manage various networking aspects. The scripts in this chapter make use of one.
- DC1: For the purposes of this chapter, DC1 is just a Windows Server 2019...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.