Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Windows Server 2019 Automation with PowerShell Cookbook
Windows Server 2019 Automation with PowerShell Cookbook

Windows Server 2019 Automation with PowerShell Cookbook: Powerful ways to automate and manage Windows administrative tasks , Third Edition

eBook
€8.99 €39.99
Paperback
€49.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Windows Server 2019 Automation with PowerShell Cookbook

Chapter 2. Managing Windows Networking

In this chapter, we cover the following recipes:

  • New ways to do old things
  • Configuring IP addressing
  • Installing and authorizing a DHCP server
  • Configuring DHCP scopes
  • Configuring an IP address from static to DHCP
  • Configuring DHCP failover and load balancing
  • Configuring DNS servers, zones, and resource records

Introduction

At the heart of every organization is the network—the infrastructure that enables client and server systems to interoperate. Windows has included networking features since the early days of Windows for Workgroups 3.1 (and earlier with Microsoft LAN Manager).

Many of the tools that IT pros use today have been around for a long time, but have more recently been replaced by PowerShell cmdlets. In the New ways to do old things recipe, we look at some of the old commands and their replacement cmdlets.

Every server or workstation in your environment needs to have a correct IP configuration. In the Configuring IP addressing recipe, we look at how to set a network interface's IP configuration, including DNS settings.

As an alternative to creating static IP addresses, you can set up a DHCP server to issue IP address configuration to clients by using the Installing and authorizing a DHCP server recipe. Once your DHCP server is set up, you can use the Configuring DHCP scopes...

New ways to do old things

Networking IT pros in the Windows Server space have been using a number of console applications to perform basic diagnostics for decades. Tools such as Ipconfig, Tracert, and NSlookup are used by IT pros all over the world. The network shell (netsh) is another veritable Swiss Army Knife set of tools to configure and manage Windows networking components.

PowerShell implements a number of cmdlets that do some of the tasks that older Win32 console applications provided. Cmdlets, such as Get-NetIPConfiguration and Resolve-DnsName, are newer alternatives to ipconfig.exe and nslookup.exe.

These cmdlets also add useful functionality. For example, using Test-NetConnection enables you to check whether a host that might block ICMP is supporting inbound traffic on a particular port. ping.exe only uses ICMP, which may be blocked somewhere in the path to the server.

One administrative benefit of using cmdlets rather than older console applications relates to remoting security...

Configuring IP addressing

By default, Windows uses DHCP to configure any NICs that are found during the installation process. Once you complete the installation of Windows, you can use the settings application netsh.exe, or, of course, PowerShell to set IP configuration manually.

Getting ready

This recipe runs on SRV2.Reskit.Org. This host is a domain-joined system with an NIC that is initially set up to be configured from DHCP.

How to do it...

  1. Get existing IP address information for SRV2:
    $IPType = 'IPv4'
    $Adapter = Get-NetAdapter |
      Where-Object Status -eq 'Up'    
    $Interface = $Adapter |
      Get-NetIPInterface -AddressFamily $IPType
    $IfIndex = $Interface.ifIndex
    $IfAlias = $Interface.Interfacealias
    Get-NetIPAddress -InterfaceIndex $Ifindex -AddressFamily $IPType
  2. Set the IP address for SRV2:
    $IPHT = @{
      InterfaceAlias = $IfAlias
      PrefixLength   = 24
      IPAddress      = '10.10.10.51'
      DefaultGateway = '10.10.10.254'
      AddressFamily  = $IPType
    }
    New-NetIPAddress...

Installing and authorizing a DHCP server

In most organizations, your servers are configured with a static IP address configuration, but client computers can get IP addresses from a DHCP server. In Windows (and with most Linux, Macintosh, and mobile phones), the operating system contains a DHCP client that communicates with a DHCP server to obtain an IP address configuration (including the IP address, subnet mask, default gateway, and DNS server IP address).

Installing and authorizing a DHCP server is easy and straightforward. You can use Server Manager to achieve this. Server Manager, though, is a GUI that's layered on top of PowerShell. Alternatively, as you see in this recipe, you can use PowerShell to automate the installation and configuration of DHCP.

Getting ready

This recipe installs the DHCP service and the related management tools on the DC1.Reskit.Org computer. DC1 is a domain controller in the Reskit.Org domain and is also a DNS server.

How to do it...

  1. Install the DHCP server...

Configuring DHCP scopes

In the previous recipe, Installing and authorizing a DHCP server, you installed and authorized a DHCP server on DC1.Reskit.Org. Before that server can begin to provide IP address configuration information to DHCP clients, you need to create a DHCP scope and DHCP options. A DHCP scope is a range of DHCP addresses that your DHCP server can give out (for a given IP subnet). DHCP options are specific configuration options your DHCP server provides, such as the IP address of the DNS server. DHCP options can be set at a scope level or at a server level, depending on the needs of your organization.

Getting ready

This recipe adds and configures a DHCP scope for your DHCP service on DC1. You installed the DHCP service and authorized it by completing the Installing and authorizing a DHCP server recipe.

How to do it...

  1. Create a new DHCP scope:
    $SHT = @{
      Name         = 'Reskit'
      StartRange   = '10.10.10.150'
      EndRange     = '10.10.10.199'
      SubnetMask...

Configuring IP addresses from static to DHCP

In some cases, you may need to switch the IP address of a server from static back to DHCP. The server may have had a static IP address based on the role it used to perform a role, but you plan to repurpose this server and want to reconfigure the server to obtain IP configuration from DHCP.

Getting ready

This recipe uses SRV1 which, at the start of the recipe, has manual IP configuration, such as what you created in the Configure IP addressing recipe. In this recipe, you changed from static to DHCP configuration. Also, this recipe assumes that you have DHCP running based on the Installing and authorizing a DHCP server and the Configuring DHCP scopes recipes.

How to do it...

  1. Get the existing IP address' information:
    $IPType = 'IPv4'
    $Adapter = Get-NetAdapter |
                 Where-Object Status -eq 'up'
    $Interface = $Adapter |
                   Get-NetIPInterface -AddressFamily $IPType
    $IfIndex = $Interface.ifIndex
    $IfAlias = $Interface...

Configuring DHCP failover and load balancing

The basic installation and configuration of a single DHCP server, as shown in the two previous recipes, is straightforward. However, a single DHCP server represents a single point of failure. A standard solution to this shortcoming is to implement DHCP Failover and Load Balancing. Microsoft added this to DHCP with Windows 2012. This feature, and indeed DHCP, is still provided with Server 2019.

Getting ready

This recipe requires two servers, with one server (DC1) set up with a working and configured DHCP scope. You achieved this by using the Configuring and authorizing a DHCP server and Configure DHCP scopes recipes. This recipe needs a second server (in this case, DC2.Reskit.Org).

How to do it...

  1. Install the DHCP server feature on DC2:
    $FHT = @{
      Name         = 'DHCP','RSAT-DHCP'
      ComputerName = 'DC2.Reskit.Org'
    }
    Install-WindowsFeature @FHT
  2. Let DHCP know it's all configured on DC2:
    $IPHT = @{
      Path   = 'HKLM...

Configuring DNS servers, zones, and resource records

In Chapter 3, Managing Windows Active Directory, in the Installing Active Directory with DNS recipe, you installed a DNS server as part of the installation of AD. This enabled DC1 to be an initial DNS server that provided a home for the various DNS records that were created by AD for the Reskit.Org domain. Adding a DHCP scope with DHCP options that specify 10.10.10.10 (the IP address of DC1.Reskit.Org) means that DHCP clients use DC1 as their DNS server (and register their IP addresses with DC1).

After you perform these two recipes, DHCP clients receive IP address configuration, which includes a DNS server. Thus, DHCP clients can easily resolve IP address for each other and for the domain forest infrastructure (DNS resolution provides AD clients with IP address details for the domain controller and global catalog servers).

The DC installation process, combined with DNS auto registration, means that basic DNS operations just work for DHCP...

Left arrow icon Right arrow icon

Key benefits

  • Leverage PowerShell to automate complex Windows server tasks
  • Explore new features such as DevOps and containers, and speed up their performance using PowerShell
  • Improve PowerShell's usability and manage Windows-based environments by working through exciting recipes

Description

Windows Server 2019 is the latest version of Microsoft’s flagship server operating system. It also comes with PowerShell Version 5.1 and offers a number of additional features that IT professionals will find useful. This book is designed to help you learn how to use PowerShell and manage the core roles, features, and services of Windows Server 2019. You will begin by creating a PowerShell Administrative Environment that features updated versions of PowerShell, the Windows Management Framework, .NET Framework, and third-party modules. Next, you will learn to use PowerShell to set up and configure Windows Server 2019 networking and understand how to manage objects in the Active Directory (AD) environment. The book will also guide you in setting up a host to utilize containers and deploying containers. Further along, you will be able to implement different mechanisms to achieve Desired State Configuration. The book will then get you up to speed with Azure infrastructure, in addition to helping you get to grips with setting up virtual machines (VMs), websites, and file share on Azure. In the concluding chapters, you will be able to deploy some powerful tools to diagnose and resolve issues with Windows Server 2019. By the end of this book, you will be equipped with a number of useful tips and tricks to automate your Windows environment with PowerShell.

Who is this book for?

If you are a systems administrator, engineer, or an architect working with Windows Server 2016 who wants to upgrade to Windows Server 2019 and automate tasks with PowerShell, this book is for you. Basic knowledge of PowerShell is expected.

What you will learn

  • Perform key admin tasks on Windows Server 2019
  • Employing best practices for writing PowerShell scripts and configuring Windows Server 2019
  • Use the .NET Framework to achieve administrative scripting
  • Set up VMs, websites, and shared files on Azure
  • Report system performance using built-in cmdlets and WMI to obtain single measurements
  • Know the tools you can use to diagnose and resolve issues with Windows Server
Estimated delivery fee Deliver to Switzerland

Standard delivery 10 - 13 business days

€11.95

Premium delivery 3 - 6 business days

€16.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 28, 2019
Length: 542 pages
Edition : 3rd
Language : English
ISBN-13 : 9781789808537
Vendor :
Microsoft
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Switzerland

Standard delivery 10 - 13 business days

€11.95

Premium delivery 3 - 6 business days

€16.95
(Includes tracking information)

Product Details

Publication date : Feb 28, 2019
Length: 542 pages
Edition : 3rd
Language : English
ISBN-13 : 9781789808537
Vendor :
Microsoft
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 124.97
Windows Server 2019 Automation with PowerShell Cookbook
€49.99
Mastering Windows PowerShell Scripting
€41.99
Powershell Core 6.2 Cookbook
€32.99
Total 124.97 Stars icon
Banner background image

Table of Contents

15 Chapters
1. Establishing a PowerShell Administrative Environment Chevron down icon Chevron up icon
2. Managing Windows Networking Chevron down icon Chevron up icon
3. Managing Windows Active Directory Chevron down icon Chevron up icon
4. Managing Windows Storage Chevron down icon Chevron up icon
5. Managing Shared Data Chevron down icon Chevron up icon
6. Managing Windows Update Chevron down icon Chevron up icon
7. Managing Printing Chevron down icon Chevron up icon
8. Introducing Containers Chevron down icon Chevron up icon
9. Managing Windows Internet Information Server Chevron down icon Chevron up icon
10. Managing Desired State Configuration Chevron down icon Chevron up icon
11. Managing Hyper-V Chevron down icon Chevron up icon
12. Managing Azure Chevron down icon Chevron up icon
13. Managing Performance and Usage Chevron down icon Chevron up icon
14. Troubleshooting Windows Server Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(5 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Bronson Magnan Mar 26, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is the single resource to take an intermediate PowerShell user and supercharge their career into a Professional Windows Server Administer. You will learn how to work with remote management environments, custom repositories, package management, code-signing, JEA (Just Enough Administration), IP Address, DHCP, and DNS management, AD management, File share automation, DFS management, WSUS management, practical Container operations, IIS Administration, DSC (Desired State Configuration), Hyper-V management, Performance monitoring, Event logs, and some Azure, all with PowerShell. Even if you are a veteran PowerShell expert with Windows Server, you will learn some new ways to do things with Windows Server 2019.
Amazon Verified review Amazon
Amazon Kunde Jul 22, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Sehr gut!
Amazon Verified review Amazon
ColMike May 21, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Don't pass this book up, seriously! From soup to nuts, Thomas gives you the recipes to excel in the world of Powershell and automation. If you're not automating your server tasks on ANY version of Windows server, you're at least 15+ years behind the times. I was doing it with PERL in the early 2000s and doing it now with Powershell. Thomas gives you the tools to be ahead of your peers when it comes to Powershell. I knew this would be a great asset to have in my toolbox because I also have his Windows Server 2016 Cookbook.
Amazon Verified review Amazon
Jesse Mar 04, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good book if you like powershell comands this is a great book.
Amazon Verified review Amazon
shawn dunham Mar 14, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Enjoyed this book. Recommend for beginners-intermediate experience.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela