Windows Server 2019 & PowerShell All-in-One For Dummies book cover

Windows Server 2019 & PowerShell All-in-One For Dummies

Author:
Sara Perrott
Published: April 30, 2019

Overview

Your one-stop reference for Windows Server 2019 and PowerShell know-how

Windows Server 2019 & PowerShell All-in-One For Dummies offers a single reference to help you build and expand your knowledge of all things Windows Server, including the all-important PowerShell framework. Written by an information security pro and professor who trains aspiring system administrators, this book covers the broad range of topics a system administrator needs to know to run Windows Server 2019, including how to install, configure, and secure a system. This book includes coverage of:

  • Installing & Setting Up Windows Server
  • Configuring Windows Server 2019
  • Administering Windows Server 2019
  • Configuring Networking
  • Managing Security
  • Working with Windows PowerShell
  • Installing and Administering Hyper-V
  • Installing, Configuring, and Using Containers

If you’re a budding or experienced system administrator looking to build or expand your knowledge of Windows Server, this book has you covered.

Your one-stop reference for Windows Server 2019 and PowerShell know-how

Windows Server 2019 & PowerShell All-in-One For Dummies offers a single reference to help you build and expand your knowledge of all things Windows Server, including the all-important PowerShell framework. Written by an information security pro and professor who trains aspiring system administrators, this book covers the broad range of topics a system administrator needs to know to run Windows Server 2019, including how to install, configure, and secure a

system. This book includes coverage of:

  • Installing & Setting Up Windows Server
  • Configuring Windows Server 2019
  • Administering Windows Server 2019
  • Configuring Networking
  • Managing Security
  • Working with Windows PowerShell
  • Installing and Administering Hyper-V
  • Installing, Configuring, and Using Containers

If you’re a budding or experienced system administrator looking to build or expand your knowledge of Windows Server, this book has you covered.

Windows Server 2019 & PowerShell All-in-One For Dummies Cheat Sheet

PowerShell 5.1 is the current released version of Windows PowerShell and is the version that ships with Windows Server 2016 and Windows Server 2019. It is installed by default on these newer operating systems, but it’s also available for install on Windows Server 2008 R2 with Service Pack1, Windows Server 2012, and Windows Server 2012 R2. The last three operating systems must have Windows Management Framework 5.1 installed to support PowerShell 5.1.

Articles From The Book

7 results

General Macs Articles

How to Install and Configure Hyper-V

Windows Server 2019 offers Hyper-V, a Type 1 hypervisor. Hyper-V is a role that gets installed on a Windows Server 2019 operating system. If you want to save time, you can also download and install Windows Hyper-V Server 2019, which is a standalone product available for download that contains the Windows Hyper-V hypervisor, Windows Server drivers, and various virtualization components — the same tech that you get from installing the role. Here, you learn how to install Hyper-V from the role. The lab systems that are used for this installation are joined to the domain sometestorg.com.

Windows 10 also has a version of Hyper-V available that you can install. It’s a feature that can be enabled, and it will allow you to support virtual machines, virtual networking, and virtual storage. This is very helpful if you need to be able to run multiple operating systems in your normal day-to-day activities. This feature is only available if you’re running Windows 10 Pro, Enterprise or Education editions. It is not available on Windows 10 Home edition. The Windows 10 version of Hyper-V does not support advanced functionality like live migration, Hyper-V Replica, or SR-IOV.

How to install Hyper-V

You need to make some basic configuration decisions during the installation of Hyper-V, but they can be changed after the installation, so if you change your mind or make a mistake, don’t panic! Follow these steps to install Hyper-V:
  1. From Server Manager, choose Manage→ Add Roles and Features.
  2. On the Before You Begin screen, click Next.
  3. On the Select Installation Type screen, click Next.
  4. On the Select Destination Server screen, click Next.
  5. On the Select Server Roles screen, select Hyper-V.
  6. Click Add Features in the dialog box that pops up, and then click Next.
  7. On the Select Features screen, click Next.
  8. On the first Hyper-V screen, click Next.
  9. On the Create Virtual Switches screen, select the network adapter you want to use for the virtual switch. As you can see in the figure, you have only one adapter to choose from right now, so select it.
  10. Click Next.
  11. On the Virtual Machine Migration screen, select the Allow This Server to Send and Receive Live Migrations of Virtual Machines on This Server check box and select the Use Credential Security Support Provider check box.

    Live migrations enable you to move a virtual machine from one Hyper-V host server to another Hyper-V host server with no downtime. CredSSP is the simplest way to set up live migration, but it requires you to log into the server being migrated, so it isn’t the best for automatically moving virtual machines.

  12. Click Next.
  13. On the Default Stores screen, keep the default locations and click Next.
  14. On the Confirm Installation Selections screen, select the Restart the Destination Server Automatically If Required check box.
  15. Click Yes on the dialog box that is confirming you want to allow the reboot.
  16. Click Install.
The Hyper-V role installs, and then the server restarts. When it comes back up from the restart, you can start configuring the Hyper-V host.

How to configure Hyper-V

After Hyper-V is installed, there are many different things that you can configure or change from what you set during installation. Getting to the Hyper-V console is similar to the other roles that you install on Windows Server 2019. From Server Manager, choose Tools→  Hyper-V Manager. When Hyper-V Manager opens, you see the name of the server on which you just installed the role. Click that server, and you see the menus change to reflect some of the things that you can do with the host. If you right-click the host, you see a menu similar to the one show. This menu allows you to configure your Hyper-V host the way that you want to. To start configuring the host, click Hyper-V Settings in the menu that you got from right-clicking the server’s name.

Virtual Hard Disks and Virtual Machines

The first two configuration options — Virtual Hard Disks and Virtual Machines — allow you to change the storage location of the virtual hard disks that are used for the VMs and the location of the VM’s configuration files.

NUMA Spanning

The third option, Non-Uniform Memory Access (NUMA) Spanning, shown in the following figure, allows you to set the host to act as a NUMA node. This allows VMs to use resources from the server they’re on as well as other servers that are configured to be NUMA nodes. This means that a virtual machine can have more CPU or RAM than what is on the one physical host, if another host which is also a NUMA node is sharing that resource. This has an impact on performance so I wouldn’t recommend it unless you’re using it in a lab or development environment. Avoid using this in production environments.

Live Migrations

Assuming you followed along in the installation of Hyper-V, your Live Migrations section should have a check mark in the Enable Incoming and Outgoing Live Migrations check box. On this screen, you can specify how many live migrations can happen at any given time. The default here is two, as shown here. You can also specify a particular IP address if you want Live Migration to happen over a different interface than the rest of the traffic. There is a plus sign next to Live Migrations. If you click that, you get the option for Advanced Features. Advanced Features is where you can change what kind of authentication you want to use for migrations. This is set to CredSSP right now (if you followed the installation instructions), and this is where you can choose Kerberos if you would like. You can also choose performance options from here. Your choices are TCP/IP, Compression, or SMB. I recommend leaving this on Compression.

Storage Migrations

Storage Migrations allows you to move VM storage with no downtime to the virtual machine. It’s very helpful when moving to a new storage array, or when getting ready to perform maintenance on a storage array because you can move the storage with the virtual machine still powered on. In this section, you can decide how many storage migrations you want to allow to happen at the same time. The default setting for this screen is two.

Enhanced Session Mode Policy

Enhanced Session Mode Policy allows your Hyper-V host to connect to your VMs over Remote Desktop Protocol (RDP). You may be wondering why you would want to allow that. When you use RDP to connect, you can pass local devices to your VMs like disk drives, flash drives, and other peripherals. You also gain a shared clipboard that allows you to copy and paste, and it improves support for viewing the VMs on a higher-resolution monitor. This setting is disabled by default on Windows Server 2019 so you need to enable it if you want to use this feature.

Replication Configuration

You can set up your Hyper-V host to act as a Hyper-V Replica. When a Hyper-V host is configured as a replica, VMs are copied to it from the primary Hyper-V servers. If the primary Hyper-V server ever experienced a major malfunction, the replica server can bring up the VMs that are kept in a powered-off state. You can specify whether you want replication traffic to be sent plaintext or encrypted. I always recommend using encryption when it’s available. And you can also select whether you want to allow replication from any server that can authenticate, or if you want to limit replication to specific servers. This screen is shown here.

Keyboard

The Keyboard screen is one of the user settings. You can specify whether key combinations like Alt+Tab, for example, will apply to the physical computer the keyboard is attached to, the VM, or on the VM but only if the VM is full screen.

Mouse Release Key

If you haven’t installed the VM drivers, you can set which key combination you want to use to release the mouse so that you can use it outside of the VM. Unless there is a good reason not to, install the VM drivers.

Enhanced Session Mode

Enhanced Session Mode is enabled for the user by default. It allows you to use a remote desktop connection to pass through drives, printers, and so on, and to use the shared clipboard.

Reset Check Boxes

All this setting does is reset check boxes that are used to hide pages or messages when they’re checked. It doesn’t reset anything else.

Virtual Switch Manager

When you right-click your Hyper-V host, you may notice an option for Virtual Switch Manager. This selection allows you to create virtual switches that your VMs can use to communicate on the network. There are three types of switches that you can use within Hyper-V:
  • External: Allows you to connect to a physical network
  • Internal: Allows the virtual machines to communicate with other virtual machines on the same switch and with the host
  • Private: Only allows virtual machines to communicate with other virtual machines on the same switch
Having the right type of switch to support your use case is critical if you want your Hyper-V deployments to succeed. The screen is shown in the following figure.

Virtual SAN Manager

Also in the menu for your Hyper-V host is the Virtual SAN Manager. This allows you to connect your Hyper-V host to a Fibre Channel SAN. This is especially helpful for large organizations that have invested in Fibre Channel technology. You can see in the following figure that you can define the World Wide Node Name (WWNN) for the Fibre Channel port that is on the Hyper-V host.

Fibre Channel SANs utilize special switching equipment to support high-speed, low-latency storage networks. Systems that use Fibre Channel need special storage network adapters installed, which are referred to as host bus adapters (HBAs).

General Macs Articles

What is Hyper-V in Windows Server 2019?

In the technology field, there is always the next hot thing that everybody starts talking about. Virtualization was one of those topics when it first made its appearance. Microsoft’s virtualization product is called Hyper-V. Virtualization has enabled IT professionals to better use the resources that have been purchased and has led to the creation of cloud computing services.

Introduction to virtualization

Every organization used to have physical servers. In most cases, they followed best practices and one server was dedicated to one application. This often led to wasted resources because the application didn’t actually need all the central processing unit (CPU) and random access memory (RAM) it was given, so those resources would sit idle. At the same time, the organization was paying for power and cooling for a server that wasn’t necessarily doing anything at the moment. The amount of time it took to stand up a new server could be an issue for projects that were time-sensitive. With each physical server, you had to rack it, cable it, configure it, and install software on it. Provisioning new servers for large projects could take weeks to months, especially if multiple teams were involved. Virtualization was a game changer. Instead of buying individual smaller servers to run single applications, an organization could purchase bigger, more powerful servers to run a hypervisor of some kind that would, in turn, run multiple virtual servers, referred to as virtual machines (VMs). By purchasing larger servers to run the smaller workloads, organizations were able to save on power and cooling costs. They were also able to reduce the amount of time needed to go to market, because the virtualization administrator was typically the one who would spin up the server operating system in a VM, set up the networking, and perform the basic configuration tasks like assigning IP addresses and other necessary steps. Virtualization really streamlined the process for system administrators and organizations to be able to build servers quickly in response to the needs of other teams for projects or for expanding the existing capacity to support applications. It also simplified recovery efforts when configured properly because VMs on a failed host could be transferred to another host.

You sometimes hear hypervisors referred to as hosts and virtual machines referred to as guests. If you run into this terminology, don’t let it confuse it. These terms are used across all types of virtualization technologies.

Type 1 and Type 2 hypervisors

Before diving into the difference between Type 1 and Type 2 hypervisors, make sure you understand what a hypervisor is. The hypervisor is essentially a process that allows you to create, run, and manage VMs. The hypervisor is ultimately responsible for presenting resources to the VMs that are running on it, including CPU, RAM, networking, and storage.

Most of the hypervisors let you overprovision VMs, meaning that you can assign resources that are not necessarily available. This may work for you if your workloads are very small, but if there are spikes in the workloads, or if VMs take too many resources, then the hypervisor could become starved for resources, which could impact all your VMs that are running on that hypervisor. Do not over-provision your VMs.

Type 1 hypervisors

Type 1 hypervisors are also referred to as bare-metal hypervisors. This is because the software for the hypervisor can run directly on the host system’s hardware. Type 1 hypervisors provide the best performance and security of the hypervisors, but some of them are more complex that others to set up. Here are some examples of the more common Type 1 hypervisors:
  • Microsoft Hyper-V
  • VMware ESXi
  • Oracle VM Server
  • KVM
  • Citrix XenServer

Type 2 hypervisors

Type 2 hypervisors are referred to as hosted hypervisors. They require an operating system to be able to install and run. Type 2 hypervisors are usually easier to install and configure, but they’re less secure and not as performant as Type 1 hypervisors because they don’t have direct access to the host system’s hardware. Here are some examples of the more common Type 2 hypervisors:
  • Oracle VirtualBox
  • VMware Workstation
  • VMware Fusion

General Macs Articles

How to Install Containers on Windows Server 2019

Containers are a game-changing technology — especially for teams that have developers who need dynamic environments to work from. A developer can launch a container that supports the needs of her application within minutes, and many of the container images are purpose build with the various programming frameworks called out in the title of the container image. Windows Server 2019 supports two variations on containers:

  • Windows container: The Windows container is the traditional container model. It’s fast, lightweight, and easy to use. The downside is that it shares the kernel with the host operating system (OS).
  • Hyper-V container: If you have a workload that requires different versions of the kernel, or highly secure workloads that can’t share a kernel, the Hyper-V container is the better choice. The Hyper-V container has a higher performance hit on the host server, but because it runs each virtual machine (VM) in its own container, you can have containers that have different versions of the kernel, and you have true isolation because the container is not sharing the kernel of the host OS with the host and other containers.
The best thing about this conversation is that you don’t need to decide on one type or the other type. Containers can go from being Windows containers to Hyper-V containers. In this chapter, I show you how to install Windows containers and Hyper-V containers, as well as how to install the Docker pieces that are needed to make everything work.

How to install Windows containers

Installing Windows containers is simple. You just enable the feature, and then install Docker. This section covers installing the feature.
  1. From Server Manager, choose Manage → Add Roles and Features.
  2. On the Before You Begin screen, click Next.
  3. On the Select Installation Type screen, click Next.
  4. On the Select Destination Server screen, click Next.
  5. On the Select Server Roles screen, click Next.
  6. On the Select Features screen, select Containers (shown in the following figure), and then click Next.
  7. On the Confirm Installation Selections screen, click Install.
  8. Click Close and restart the server.

How to install Hyper-V containers

To install Hyper-V containers, you also have to install the Hyper-V role. You can install them both at the same time. Follow these steps:
  1. From Server Manager, choose Manage→Add Roles and Features.
  2. On the Before You Begin screen, click Next.
  3. On the Select Installation Type screen, click Next.
  4. On the Select Destination Server screen, click Next.
  5. On the Select Server Roles screen, select Hyper-V, click Add Features, and then click Next.
  6. On the Select Features screen, select Containers and then click Next.
  7. On the Hyper-V screen, click Next.
  8. On the Create Virtual Switches screen, select your network adapter, and click Next (see the following figure).
  9. On the Virtual Machine Migration screen, click Next.
  10. On the Default Stores screen, click Next.
  11. On the Confirm Installation Selections screen, click Install.
  12. After the installation is complete, click Close and then restart the server.

How to install Docker

At this point, you’ve at least got the containers feature installed. You may have even installed the Hyper-V role and the containers feature at the same time. Now you need to install the Docker Engine. This is the piece that really ties all the other pieces together. You’ll need to open PowerShell to run these commands, as well as the commands that follow under “Test Your Container Installation.” To open PowerShell, right-click on Start and select Windows PowerShell (Admin). After you’ve opened PowerShell, your first step is to install the Microsoft Package Provider for Docker. This is done with the following command: Install-Module -Name DockerMsftProvider -Repository PSGallery -Force Now you can install the latest version of Docker with the following command: Install-Package -Name docker -ProviderName DockerMsftProvider After Docker is installed, you need one more restart. You can do this through the graphical user interface (GUI), or you can just type the following into PowerShell: Restart-Computer -Force These commands are shown in the following figure. If everything went well, you get no output. The PowerShell prompt will simply return, and you can run the next command.

Test your container installation

After your server is configured and Docker is installed, you’ll want to test to ensure that your container installation is working properly.

Test a Windows container

There is a simple way to test that your Windows container installation is installed properly: Download and run a container image. One of my favorites is a sample image because it prints out a “Hello world”–style message and then exits. To run this test, you use the docker run command. Because the container image is not downloaded yet, it will download the container image first, and then run it. If you want to stage the image so you can play with it later, you can use the docker pull command instead of docker run, and it will only download the container image. Here is the command to download the sample container: docker pull microsoft/dotnet-samples:dotnetapp Note that the download may take a few minutes because it's pulling down a copy of Nano Server. You can watch the progress on the screen. See the following figure for the output from running the command.

The container images must use the same kernel version as the container host. If you try to run the container with a kernel version that doesn’t match the container host’s kernel version, you’ll get an error similar to the screenshot in the following figure. Notice the first line of the error, which ends in “The container operating system does not match the host operating system.”

Test a Hyper-V container

Testing the Hyper-V container is similar to testing a Windows container, but because the kernel isn’t shared, you have far more freedom as far as which container images you want to run. The command itself is similar — you just need to include --isolation=hyperv to tell it that you want it to launch the container as a Hyper-V container rather than a Windows container. docker run –-isolation=hyperv microsoft/dotnet-samples:dotnetapp As you can see in the following figure, the container image, which was downloaded previously in the Windows container section, ran and gave us the Hello message with the super adorable .NET Foundation’s robot mascot.