Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Windows Server 2016 Cookbook
Windows Server 2016 Cookbook

Windows Server 2016 Cookbook: Sauté your way through more than 100 hands-on recipes designed to prepare any server administrator to work with Windows Server 2016

eBook
$35.99 $51.99
Paperback
$65.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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

Windows Server 2016 Cookbook

Chapter 1. Learning the Interface

In an effort to become familiar with the look and feel of Windows Server 2016, you will learn how to navigate through some daily tasks using the graphical interface. On our agenda in this chapter are the following recipes:

  • Shutting down or restarting the server
  • Launching Administrative Tools
  • Using WinKey + X for quick admin tasks
  • Using the search function to launch applications quickly
  • Managing remote servers from a single pane with Server Manager
  • Using PowerShell to accomplish any function in Windows Server
  • Installing a role or feature
  • Administering Server 2016 from a Windows 10 machine
  • Identifying useful keyboard shortcuts in Server 2016
  • Setting your PowerShell Execution Policy
  • Building and executing your first PowerShell script
  • Searching for PowerShell cmdlets with Get-Help

Introduction

Windows 8 and Server 2012 brought us a drastic change in the way that we interfaced with the Windows operating system, and most of us didn't think that change was for the better. By now I assume you have all seen, used, and are hopefully deploying Windows 10 on your client computers, which brings some relief with regard to the user interface. With Windows 10 we have kind of a mix between Windows 7 and Windows 8, and it fits the needs of most people in a better way. Just like the last couple of rollouts of the Microsoft Windows operating systems, the Server platform follows on the heels of the Desktop version, and the look and feel of Windows Server 2016 is very much like Windows 10. In fact, I would say that Windows 10 and Windows Server 2016 are more alike than the Windows 7/Server 2008 combination or the Windows 8/Server 2012 combination.

If you have been using Windows 10, you already have a good head start for successfully interfacing with Windows Server 2016. However, if you are still using older equipment and haven't had a chance to really dive into the latest and greatest operating systems, these big changes in the way that we interact with our servers can be a big stumbling block to successfully utilizing the new tools. Many differences exist when comparing Server 2016 to something like Server 2008, and when you are working within three levels of Remote Desktop Protocol (RDP), bouncing from one server to another, all of these little differences are compounded. It suddenly becomes difficult to know which server it is that you are working on or changing. Let's have a show of hands, how many of you have mistakenly rebooted the wrong server? Or even more likely, how many of you have rebooted your own computer while you were trying to reboot a remote server? I know I have! And not just once.

Hope is not lost! I promise you that, once you learn to manage the interface, rather than letting it manage you, some of these changes may start to seem like good ideas. They can increase productivity and the ease of accomplishing tasks—we just need some pointers on making the best use of the new interface.

The recipes in this chapter are dedicated to doing just that. Let's work together to gain a better understanding of why the interface was built the way it is, and learn to take advantage of these new screens and settings.

Shutting down or restarting the server

I just couldn't resist starting with this one. Yes, this seems trivial. Silly even. However, the number of times that I have watched a simple server restart consume more mouse clicks than creating a domain controller has convinced me that this needed to be in the book. Perhaps the shutdown and restart options were hidden away purposefully, because once your system is up and running, there is not often a need to accomplish either of these tasks. When first configuring the box, though, it is very common to have to reboot a couple of time or to shut down a machine to move it to another location. Let's face it, it doesn't seem to matter how many years computers have been around, many times the magical reboot is still the fix—all answer to most problems, even if we have no idea why.

Getting ready

To go through this recipe, you will need a Windows Server 2016 system online. There are no other prerequisites.

How to do it…

Let's take a look at three different ways to shut down or restart your system. The first is going to be the most commonly employed. The second is still being used by quite a few folks who had to work hard at getting this strange location in their heads during the Windows 8 rollout, and they have continued to use it from that point forward. The third is less commonly known but is by far my favorite when tasked with restarting a remote server.

The first option, thankfully, is in a location that actually makes sense. I say thankfully because when Server 2012 was released, this option didn't exist, and finding the restart function was much more difficult. Just like we had always been able to do prior to the Windows 8 rollout, we can simply click on the Start button, and see right there near the bottom that we have Power control options available to us.

How to do it…

Now, when you click on Shut down or Restart, you are asked to supply a reason why you are restarting. Common sense tells us that if you are manually clicking on the Restart button, there is a pretty good chance you are actually intending to restart the server, right? A planned occurrence? But what is the default option that presents itself? Other (Unplanned). Alas, this silly default option is certainly going to cause us log files full of unplanned restarts, even though all of those restarts were actually planned. Because let's be real—nobody takes the time to change that dropdown menu before they click Continue.

How to do it…

The second method to accomplish shutting down or restarting is by right-clicking on the Start button. We will discuss this little menu that is presented when right-clicking on Start in our next recipe, but for the sake of a quick shut down or restart, you can simply right-click on the Start button, and then choose Shut down or Sign out.

How to do it…

Each of the previous two examples runs the risk of rebooting  the wrong system. Depending on how many layers of remote connections, such as RDP, you are using, it is fairly easy to reboot your own computer or the wrong server instead of the server you intended to reboot, because it is fairly easy to click on the Start button of a different system than the one you intended in the first place. The most definitive, and dare I say the most fun way of restarting your server is to utilize a Command Prompt. Doing this gives you the opportunity to double check that you are manipulating the correct machine. Open up a Command Prompt and run a quick hostname check to make sure you are restarting the one you really intend to. Then utilize the shutdown command to take care of the rest. This process can be especially helpful when logged into remote servers using RDP. Use the following commands to perform the explained operations:

hostname 
shutdown /r /t 0

If you were to simply type shutdown, the server would shut itself down in 60 seconds. Using /r indicates a restart rather than a shutdown, and /t 0 is a timing flag that indicates the number of seconds the server should wait before restarting. Specifying slash zero here tells it to wait for zero seconds before initiating the restart.

How to do it…

How it works…

Shutting down or restarting a server doesn't require a lot of explanation, but I hope that this small recipe gets some thought going about creative ways to do regular tasks. As you will see throughout this book, you can accomplish anything in Windows Server 2016 through the use of commands or scripts. You could easily turn the shutdown command, the last example that we tested in this recipe, into a batch file, and place it on the Desktop of each of your servers as a quick double-click option for accomplishing this task.

However, I work with RDP windows inside RDP windows very often. When you're bouncing around between a dozen servers that all have the same background image, I have decided that the only sure-fire way to make sure you are restarting the correct device is to do a quick hostname check before you initiate the restart. If you are interested in discovering all of the available flags that are available to use with the shutdown command, make sure to type in shutdown /? sometime to take a look at all of the available options.

Tip

Using the Command Prompt is also an easy way to log off a server. Let's say you are layers-deep in RDP and want to log off from a single server (not all of them). Are you sure you clicked on the Start button of the right server? Instead, open up a prompt and simply type Logoff.

Launching Administrative Tools

Earlier versions of Windows Server placed all of the Administrative Tools in a self-named folder right inside the Start menu. This was always a quick and easy place to visit in order to see all of the Administrative Tools installed onto a particular server. This location for the tools disappeared as of Server 2012, because of the infamous Start Screen. I am glad to say that a more traditional-looking Start menu has returned in Windows Server 2016, and inside it once again is a link to the Windows Administrative Tools. However, as you also know there is this thing called Server Manager that loves to present itself every time that you log in to a server. Since Server Manager is already on your screen most of the time anyway, it is actually the fastest way to launch these Administrative Tools that you need to utilize so often. Let's take a look at launching your commonly used infrastructure tools right from inside the Server Manager interface.

Getting ready

All you really need is a Windows Server 2016 machine online. The more roles and services that you have running on it, the more options that you will see on your screen as we navigate these menus.

How to do it…

To launch Administrative Tools from your Desktop, perform the following steps:

  1. Open up Server Manager. In fact, if you just logged into the server, it's probably already open for you.
  2. Click on Tools in the upper-right corner.

There you go. A full list of all the Administrative Tools installed onto that server. Heading into this list is also a quick way of taking a look into what a particular server is doing, which you can take an educated guess at based on what roles and services are installed. By looking at the following screenshot, we can see that this server appears to be a domain controller that is also running DNS and DHCP, because all of the related tools are available to choose in this list. That is accurate, as this is my DC1 domain controller server. It is important to note that your server may be running components that do not show up in this list. For example, if you install a role via PowerShell and do not enter the parameter to also install the management tools for that role, it is possible that you could have a server where the role is up and running, but the management tools simply have not been installed. In that case, those tools would not show up in this list.

How to do it…

How it works…

Since Server Manager likes to open automatically when logging in, let's make quick use of it to open the tools that we need to do our jobs. Another way to have easy access to your tools from the Desktop is to create shortcuts or to pin each of them to your taskbar. Sometimes this isn't as easy as it sounds. In the past, these tools were all grouped together in the Administrative Tools folder, so you didn't have any reason to memorize the exact names of the tools. While you can access them that way again in Server 2016, that folder may or may not appear inside the Start menu depending on how the server is configured, because it appears as one of the live tiles. If you click on the Start button, you could try using the search function to find the tool you are looking for, but its name may not immediately come to you. If you're a consultant working on someone else's server, you may not want to pin anything to their Desktop anyway, and you certainly don't want to resort to using Bing in front of them to look up the name of the tool. So I like to stick with launching Administrative Tools from Server Manager since it always exists, and the tools will always be available inside that menu.

Using WinKey + X for quick admin tasks

There are some functions in Windows that a server administrator needs to use all the time. Instead of making shortcuts or pinning them all to the taskbar, let's get to know this hidden menu, which is extremely useful for launching these commonly used admin tools.

Getting ready

A running Windows Server 2016 machine is all we need to highlight this one. In fact, this menu also exists on any Windows 10 computer, so make use of it often!

How to do it…

There are two ways to open this little menu. While you are in the Server 2016 Desktop, you can perform either of these steps:

  1. Hold down your Windows key (WinKey) on the keyboard and press X.
  2. Hover your mouse over the Windows flag in the lower-left corner of the Desktop—the Start button—when you right-click on that button you will see a menu, shown in the following screenshot:

    How to do it…

How it works…

This little quick-tasks admin menu is very easy to open and is very convenient for launching programs and settings that are accessed often. I won't talk too much about what particulars are in the menu as it's pretty self-explanatory, but I use this menu multiple times per day to open up the System properties and the Command Prompt, as it has an option to open an administrative Command Prompt right from the menu.

Tip

Look at that, you can also shut down the server from here!

Using the search function to launch applications quickly

The Start screen in Windows Server 2012 was not the greatest idea to come out of Microsoft, and unfortunately what it did was train people to no longer click on the Start button, so that we didn't have to deal with the Start screen. Windows 10, and therefore Windows Server 2016, have moved back to a more traditional Start menu, but it is going to take a little bit of time to retrain ourselves to make use of it on a daily basis. I know it will for myself, anyway. Ever since Windows 7 was released, I have been using the Start menu for one critical function in my daily workflow: searching. Let's explore the search capabilities of Server 2016, which can be accessed with a single press of a button.

Getting ready

For this recipe, you will need a Windows Server 2016 system online.

How to do it…

There are two quick ways that you can search inside Server 2016, and they are right next to each other. If you take a look in the lower-left corner of your screen inside the taskbar, you will see a little magnifying glass next to the Start button. Looks like a search function to me. Click on that button, and you can start typing the name of whatever you would like to search for. In the following screenshot, you can see that I have clicked on my magnifying glass and typed cmd in order to find the Command Prompt application.

How to do it…

Search results are presented at the top of that screen, and you can choose what you are looking for accordingly. This is a quick, easy search—but I'm not a fan of it because I don't like using my mouse unless I have to. Grabbing my mouse in order to click on the magnifying glass slows down what I'm trying to do while my hands are on the keyboard, so let's take a look at a faster way to search. No matter where you are in Windows Server 2016, no matter what applications you have open, you can always press the WinKey on your keyboard to open up the Start menu, right? What you may not know is that as soon as your Start menu is open, you can immediately start typing anything in order to search for it. If you need to open Command Prompt, press WinKey and type cmd. If you need to search for a document called Text1, press WinKey and type Text1. I employ this method of opening applications all day every day. This way I don't have to pin anything, I don't have to create any shortcuts, and most importantly, I don't have to use my mouse in order to launch applications.

How to do it…

How it works…

From the Start menu, we can search for anything on the server. This gives us the ability to quickly find and launch any program or application that we have installed. This includes Administrative Tools. Rather than moving into Server Manager in order to launch your administrative consoles from the Tools menu, you can also search for them on the Search menu, and launch from there. It also gives us the ability to find files or documents by name. Another powerful way to use the search function in Windows Server 2016 is to open any kind of setting that you might want to change. In previous versions of Windows, you had to either memorize the way to get into the settings that you wanted to change or you had to open up Control Panel, where you had to poke and prod your way around until you stumbled upon the one that you were looking for. Now it is a very simple matter of pressing the Windows key, typing the first few characters of the setting or program you want to launch, and pressing Enter.

Another common task to perform from the Search screen is to right-click on the application that you are trying to launch and pin it somewhere. When you right-click on a program from the Search screen, you see options to pin the program to either your Start menu or to the taskbar. This will create a quick-launch shortcut on either the main Start menu or on the taskbar of the Desktop mode, giving you easier and faster access to launch those applications in the future.

Managing remote servers from a single pane with Server Manager

As you have already noticed, Server Manager has changed significantly over the past couple of versions of Windows Server. Part of these changes are a shift in mindset where the emphasis is now placed on remote management of servers. Server Manager in Windows Server 2016 can be used to manage and administer multiple systems at the same time, all from your single pane of glass, the monitor where you are sitting. In this recipe, you are going to learn how to manage both the local server we are logged into, as well as a remote server, from the same Server Manager window.

Getting ready

For this recipe, we need two servers. One is the machine we are physically logged into. Another is a server on the same network that we can contact from our primary server so that we can manage it from our local Server Manager.

How to do it…

To manage a local as well as a remote server from the same Server Manager window, perform the following instructions:

  1. Log in to your primary server and launch Server Manager. You will see in the upper-left corner that the only server you have listed is the Local Server that we are logged into.

    How to do it…

  2. Now head over toward the top-right of Server Manager and click on the Manage button. In this menu, click on Add Servers.

    How to do it…

  3. If your servers are part of a domain, finding remote machines to manage is very easy by simply selecting them from the default Active Directory tab. If they are not yet joined to your domain, you simply click over to the tab labeled DNS and search for them from that screen.

    How to do it…

  4. After adding the servers that you want to manage, if you go ahead and click on All Servers in the left window pane, you will see the additional servers listed that you have selected. If you double-click or right-click on those remote server names, you have many options available to you to remotely manage those machines without having to log into them.

    How to do it…

Tip

Note that certain servers could resist being manipulated in this way. It is possible to restrict remote management on servers through Group Policy. If that has been done in your environment, you may find that remotely administering them from a centralized console is not possible, and you would have to lift those restrictions on your servers.

How it works…

Server Manager makes use of the Windows Remote Management (WinRM) tools to remotely manipulate servers. Historically, most of us who administer Windows Servers make extensive use of RDP, often having many windows and connections open simultaneously. This can cause confusion and can lead to tasks being accomplished on servers for which they are not intended. By using Server Manager from a single machine to manage multiple servers in your network, you will increase your administrative efficiency as well as minimize human error by having all management happen from a single pane of glass.

This recipe is written with the most common network scenario in mind, which is a domain environment where both servers have been joined to the domain. If you are working with standalone servers that are part of a workgroup, rather than being joined to a domain, you will have some additional considerations. In the workgroup scenario, WinRM will need to be enabled specifically, and the Windows Firewall will have to be adjusted in order to allow the right ports and protocols for that WinRM traffic flow to happen successfully. In general, though, most of you will be working within a Microsoft domain network, in which case these items are not necessary.

See also

  • The Administering Server 2016 from a Windows 10 machine recipe

Using PowerShell to accomplish any function in Windows Server

An incredibly powerful tool in Windows Server 2016 is PowerShell. Think of PowerShell like a Command Prompt on steroids. It is a command-line interface from which you can manipulate almost anything inside Windows that you may care to. Better yet, any task that you may wish to accomplish can be scripted out in PowerShell and saved off as a .ps1 script file, so that you can automate large tasks and schedule them for later, or at regular intervals. In this recipe, let's open up PowerShell and run some sample commands and tasks just to get a quick feel for the interface. In a later chapter of the book, we will do some more specific tasks with PowerShell to go even deeper into the technology.

Getting ready

To start using PowerShell, all you need is a server with Windows Server 2016 installed. PowerShell is installed and enabled by default.

How to do it…

To get a feel of using PowerShell, perform the following steps:

  1. PowerShell used to exist in the taskbar by default, which was smart because we really should be pushing people to use it rather than Command Prompt, right? Unfortunately, PowerShell is not in the taskbar by default in Server 2016, but the Windows Store is...? Explain that one to me some day. So our first step to working in PowerShell is finding it. Thankfully, we know how to search for applications now, so I'll just press my WinKey and type PowerShell. Once my search result is displayed, I am going to right-click on Windows PowerShell and choose to Run as administrator.

    How to do it…

  2. Test out some commands that you are familiar with from using the Command Prompt, such as dir and cls. Since you are able to make use of these familiar commands, PowerShell can really be your one and only command-line interface if you choose.
  3. Now let's try some of the PowerShell secret sauce, one of its cmdlets. These are special commands that are built into Windows and allow us to do all kinds of information gathering, as well as manipulation of server components. Let's start by pulling some data. Maybe take a look at what IP addresses are on the system with Get-NetIPAddress.

    How to do it…
  4. The previous command probably gave you a lot more information than you needed, since most companies don't make use of IPv6 inside their network yet. Let's whittle this information down to the IPv4-specific info that you are most likely interested in. Enter Get-NetIPAddress -AddressFamily IPv4 to attain it.

    How to do it…

How it works…

PowerShell has so many commands and cmdlets, we just wanted to get a feel for launching the program and pulling some data with this particular recipe. There are countless Get commands to query information from the server, and as you have seen those cmdlets have various parameters that can be appended to the cmdlets to pull more specific data to meet your needs. To make things even better, there are not only Get cmdlets, but also Set cmdlets, which will allow us to make use of the PowerShell prompt to configure many aspects of the configuration on our server, as well as remote servers. We will dive further into PowerShell in a later chapter.

Installing a role or feature

You've installed the Windows Server 2016 operating system onto a piece of hardware. Great! Now what? Without adding roles and features to your server, it makes a great paper weight. We're going to take the next steps here together. Let's install a role and a feature into Windows so that we can start making this server work for us.

Getting ready

As long as you have a Windows Server 2016 installed and running, you are ready to install roles and features onto that machine.

How to do it…

To install a role and a feature into Windows, perform the following steps:

  1. Open Server Manager. In the middle of the screen, you'll see a link that says Add roles and features. Click on that link.
  2. Click Next on the first summary screen and you will come to a choice on the second page. For most roles and features, we want to leave it set at the top bullet, which is Role-based or feature-based installation. If we were configuring Remote Desktop Services, which we will discuss in another chapter, then we would choose the second option.
  3. Now we choose where we want to install a new role or feature. This is a neat page, as we can choose from any server that we have added into our Server Manager, or we can even choose to install a role or feature into a virtual hard disk. I am running the Add Roles Wizard from DC1, but I want to install the IIS role onto WEB1. Rather than having to log into WEB1 to accomplish this task, I will do it right from here. In the following screenshot, you can see WEB1 listed as a server that I can install a role onto, even though I am opening this console on the DC1 server.

    How to do it…
  4. Scroll down and choose the role that you want to install. For WEB1, I am choosing the Web Server (IIS) role. Then click Next.

    Note

    You can install more than one role or feature at a time. Some roles require additional components to be installed for them to work properly. For example, when I chose to install the IIS role and clicked Next, I was prompted about needing to install some management tools. Simply click on the Add Features button to automatically add the items that it needs to perform correctly.

  5. Now choose any features that you would like to install. For example, in order to do some network connectivity testing later, go ahead and select Telnet Client from the list.
  6. Read and click Next through the informational messages that are displayed. These messages will vary depending on which roles and features you have installed.
  7. The final screen is your installation summary. If everything looks correct, go ahead and click on Install.

After your roles and features have finished installing, the server may or may not have to reboot. This depends on whether or not the role installation requires it. Following installation, or following the reboot, if your new role needs any additional configuration or setting up to be completed, you will be notified at the top of the Server Manager screen.

How it works…

Adding roles and features to a Windows Server is something that every administrator will have to do sooner or later. These items are necessary to turn on the functions in the server that will perform tasks that need to be performed in your environment. Adding roles is quite straightforward. However, it is interesting to see the options that are available to add more than one role or feature at a time. Moreover, the ability to remotely install these items for servers in your network that you are not logged into is intriguing.

Administering Server 2016 from a Windows 10 machine

In the Managing remote servers from a single pane with Server Manager recipe, we discussed remotely administering another server by using Server Manager. Did you know we can accomplish the same remote management by using our day-to-day Windows 10 computer? We will install and use the Remote Server Administration Tools (RSAT) to take even more advantage of Server 2016's remote management ideology.

Getting ready

To test out the RSAT tools, we will need a Windows 10 client machine. We will then also need a Windows Server 2016 system online, and on the same network, which we can remotely control and manage.

How to do it…

To remotely manage a server using RSAT, follow these instructions:

  1. First, we need to download the RSAT tools. You can use Bing to search for Remote Server Administration Tools for Windows 10, or use this link to download RSAT for Windows 10: https://www.microsoft.com/en-us/download/details.aspx?id=45520. Here is also the link for the same RSAT tools in the Windows 8.1 flavor: http://www.microsoft.com/en-us/download/details.aspx?id=39296. After you install these tools onto your Windows 10 or 8.1 computer, you should now have a copy of Server Manager installed onto your computer. Go ahead and launch that from the Start menu. You can pin it to your Taskbar for quicker launching in the future, of course. In the same fashion, as with Server 2016, you can use the Manage menu to add servers to Server Manager.

    How to do it…

  2. For this recipe, I do have the machines we are working with joined to a domain, so we will take a look at adding servers that are part of the domain.
  3. Click on the Find Now button and you will see a list of server names that are remotely manageable.

    How to do it…

  4. Click on the server names that you want to administer and click on the arrow to move them over to the right side of the screen. Upon clicking on OK, you will see these new servers listed and ready for management inside your Server Manager console.

    How to do it…

How it works…

Server Manager in Windows Server 2016 is a powerful tool that can be used for the management of not only the local server but also remote servers that you want to manage. If we take this even a step further and install the RSAT tools on a Windows 10 computer, this gives us the ability to launch and use Server Manager from our everyday Windows 10 computer. In doing so, we enable ourselves to add roles, view events, and restart servers, all from our own desk. Managing servers using these tools will increase productivity and decrease errors because your entire infrastructure of servers can be available within a single window. This is much more efficient than using the RDP client to connect to many different servers, all in different windows. If you've never tried using RSAT to manage servers, give it a try!

See also

  • The Managing remote servers from a single pane with Server Manager recipe

Identifying useful keyboard shortcuts in Server 2016

I prefer using a keyboard over a mouse any day, for almost any task. There are numerous keyboard shortcuts and tips and tricks that I employ on a daily basis and I want to test them out with you in this recipe. Some of these shortcuts have been around for years and will work with multiple versions of Windows Server; some are new in the Server 2016 operating system. They will all be useful to you as you start working with servers in your network.

Getting ready

We are going to run these commands and keyboard shortcuts while logged into a Windows Server 2016 machine.

How to do it…

  • Windows key: Opens the Start menu, where you can immediately start typing to search for programs.
  • Windows key + X: Opens the Quick Links menu, which we discussed in an earlier recipe.
  • Windows key + I: Opens Windows Settings options.
  • Windows key + D: Minimizes all open windows and brings you back to the Desktop.
  • Windows key + R: Opens the Run box. Launching applications this way is often faster than using the Start menu, if you know the executable name of the application you are trying to launch.
  • Windows key + M: Minimizes all windows.
  • Windows key + E: Opens File Explorer.
  • Windows key + L: Locks the computer.
  • Windows key + Tab: Takes you into the new Task View options.
  • Window key + Ctrl + D: Creates a new virtual Desktop from Task View.
  • Windows key + Ctrl + F4: Closes the current virtual Desktop.
  • Windows key + Ctrl + Left or Right Arrow: Move between different virtual Desktops.
  • Windows key + 1 or 2 or 3 or…: Launches applications that are pinned to your taskbar, in order. So the first application pinned to the taskbar would open with WinKey + 1, for example.
  • Alt + F4: Exits the program you are currently working in. This is especially helpful in full-screen apps—like those from the Windows Store - where it is not always obvious how to exit the program with your mouse.
  • Alt + Tab: Displays a list of open programs so you can hop between them.
  • Shift + Delete: Holding down Shift while pressing Delete deletes files without placing them into the Recycle Bin.
  • Using Tab inside Command Prompt or PowerShell: I cannot believe that I went years without knowing about this one. When you are working inside Command Prompt, if you type the first letter of a file or folder that exists in the directory where you are working and then press the Tab key, it will auto-populate the rest of the filename. For example, you may be trying to launch a Microsoft update file with a filename that is 15 characters and comprises a mix of numbers and letters. No need to type out that filename! Let's say the file starts with KB. Simply navigate to the folder where your installer exists, type KB, and press Tab. The full filename is populated inside Command Prompt and you can press the Enter key to launch it.

How it works…

Keyboard shortcuts can greatly increase productivity once you are fluent with them. This is not an extensive list by any means, there are many more key combinations that you can use to launch apps, minimize and maximize windows, and do all sorts of other functions. This is a list to get you started with the most common ones that I employ often. Start using these with your daily tasks and I bet your mouse will start to feel lonely.

If you are interested in exploring more of the Windows Server 2016 key combinations available, this website is a great place to start: http://technet.microsoft.com/en-us/library/hh831491.aspx.

Setting your PowerShell Execution Policy

To say that the Windows operating system can be manipulated by PowerShell is a gross understatement. They are fully intertwined, and PowerShell can be useful for so many tasks on your servers. However, the ability to run PowerShell scripts is disabled by default on many machines. The first stumbling block that many new PowerShell administrators bump into is the Execution Policy. It's quite simple: in order to allow PowerShell scripts to run on your server, the Execution Policy must be adjusted to allow that to happen. Let's introduce our first task in PowerShell by using some commands in this recipe that will set this policy for us.

This is also a good introduction to the idea of the verb-noun syntax that PowerShell utilizes. For example, we are going to make use of cmdlets called Get-ExecutionPolicy and Set-ExecutionPolicy. The Get-(parameter name) and Set-(parameter name) cmdlets are very common across all facets of cmdlets available in PowerShell. Wrap your mind around this verb-noun syntax and you will be well on your way to figuring out PowerShell on your machines.

Getting ready

We will be working within a PowerShell prompt on our Windows Server 2016 box.

How to do it…

Follow these steps to set the PowerShell Execution Policy:

  1. Right-click on the PowerShell icon and choose Run as administrator.

    How to do it…

  2. Type Get-ExecutionPolicy and press Enter in order to see the current setting of the PowerShell Execution Policy.

    How to do it…

  3. You can see that the current Execution Policy is set to RemoteSigned. Here is a short description of the different options for the policy:
    • Remote Signed: This is the default setting in Server 2016, which allows PowerShell scripts that are locally created to run. If you try running remote scripts, they must be signed by a trusted publisher in order to execute successfully.
    • All Signed: With this setting, all scripts will only be allowed to run if they are signed by a trusted publisher.
    • Restricted: With this setting, PowerShell is locked down so that scripts will not run.
    • Unrestricted: This setting will allow PowerShell to run scripts, with or without signing.

  4. For the purposes of our recipe and to make sure scripts will run for us as we progress through these recipes, let's set our Execution Policy to unrestricted. Go ahead and use this command:
    Set-ExecutionPolicy Unrestricted
    

    How to do it…

How it works…

The PowerShell Execution Policy is a simple setting and easy to change, but can make a world of difference when it comes to running your first scripts. If configured to be more restrictive than you intend, you will have trouble getting your scripts to run and may think that you have mistyped something, when in fact the issue is only the policy. On the other hand, in an effort to make your servers as secure as possible, on machines where you don't need to execute PowerShell scripts, it makes sense to restrict this access. You may also want to read some additional information on the signing of scripts to see whether creating and executing signed scripts would make more sense in your own environment. There are some in-built server functions that rely on a certain level of security with your Execution Policy. Setting your policy to unrestricted on all of your servers could result in some functions not working properly, and you may have to increase that level of security back to remote signed.

Building and executing your first PowerShell script

Command Prompt and PowerShell are both great command-line interfaces that can acquire and configure information about our servers. Most of us are familiar with creating some simple batch files that are driven by Command Prompt, essentially programming out small tasks within these batch files to automate a series of commands. This saves time later as we do not have to type out the commands line by line, especially for common tasks or for items that we need to run during login.

PowerShell has similar functionality, the ability to write out multiple lines of PowerShell cmdlets inside a script file. We can then launch this script file as we would a batch file, automating tasks while taking advantage of the additional features that PowerShell brings to the table over Command Prompt. These PowerShell scripts are put together inside .ps1 files; let's build a simple one together to get a feel for running these scripts.

Getting ready

Our work with PowerShell today will be accomplished from a Windows Server 2016 machine. PowerShell is installed by default with Windows, and there is nothing further that we need to install.

How to do it…

Follow these steps to build and execute our first PowerShell script:

  1. Open the Start menu and type Windows PowerShell ISE. Right-click to launch this tool as an administrator. Windows PowerShell ISE is an editor for PowerShell scripts that is much more useful than opening a simple text editor such as Notepad in order to build our script.

    How to do it…

  2. Navigate to File | New from the menus in order to open a blank .ps1 script file.
  3. In your first line, type the following: Write-Host "Hello! Here is the current date and time:".
  4. From the toolbar menu, click the green arrow that says Run Script. Alternatively, you can simply press the F5 button. When you run the script, the command and output are displayed in the lower portion of the ISE window.

    How to do it…

    Cool! Okay, so far it's actually pretty lame. It's just reflecting the text that we told it to echo, but it worked. That is the nice thing about using the ISE editing tool rather than a generic text editor, you have the ability to quickly test run scripts as you make modifications.

  5. Now let's add some additional lines into our script to give us the information we are looking for. You can see a list of available commands on the right side of the screen if you would like to browse through what is available, but for our example simply change your script to include the following:
          Write-Host "Hello! Here is the current date and time:" 
          Get-Date 
          Write-Host "The name of your computer is:" 
          hostname
    
    
  6. Press the Run Script button again to see the new output.

    How to do it…

  7. Now navigate to File | Save and save your new .ps1 PowerShell script out to the Desktop.
  8. Let's test this script by launching it from within a real PowerShell command window. Right-click on your PowerShell icon in the Taskbar and choose Run as administrator.
  9. Browse to the location of the script file, I placed mine on the Desktop. Then launch the script by inputting .\filename. In my case, it looks like this: .\time.ps1.

Tip

Remember that the Tab key can be our friend in this. When browsing to your Desktop, all you need to do is input the first letter of your script filename, and then press Tab. Since I named my script Time.ps1, all I had to do was press the T and then press Tab, then Enter.

How to do it…

How it works…

In this recipe, we created a very simple PowerShell script and saved it on our server for execution. While in practice getting time and date information from your server may come faster by using the standalone Get-Date cmdlet, we use this recipe to give a small taste of the ISE and to get your scripting juices flowing. Expanding upon the ideas presented here will start to save you valuable time and keystrokes as you identify more and more ways to automate the tasks and information gathering that are part of your daily routines. The possibilities of PowerShell are practically limitless, so make sure that you open it up and start becoming familiar with the interfaces and tools associated with it right away!

Searching for PowerShell cmdlets with Get-Help

With this recipe, let's take a minute to use Get-Help inside PowerShell in order to, well, get some help! I see both new and experienced PowerShell administrators going to the Web a lot in order to find commands and the parameters of those commands. The Internet is great, and there is a ton of data out there about how to use PowerShell, but in many cases the information that you are looking for resides right inside PowerShell itself. By using the Get-Help cmdlet combined with the functions you are running or searching for, you might not have to open that web browser after all.

Getting ready

We will be running some commands from inside PowerShell on a Windows Server 2016 machine.

How to do it…

To use the Get-Help function inside PowerShell, run the following steps:

  1. Launch a PowerShell prompt.
  2. Type Get-Help.
  3. You're finished! No, I'm just kidding. Using Get-Help by itself will present you with some helpful data about the Get-Help command, but that's not really what we are looking for, is it? How about using Get-Help with a search parameter, like this:
          Get-Help Computer
    

    How to do it…

    Cool! That searched the available cmdlets and presented us with a list of the ones that contain the word Computer. Nice.

  4. Now, what if we wanted to find out some more particular information about one of these cmdlets? Maybe about Restart-Computer; that sounds like something we might use often. Use the following command:
          Get-Help Restart-Computer
    

    How to do it…

    Now we're really cooking! This is wonderful information. Basically, this is exactly what you would find if you were looking for information about the Restart-Computer cmdlet and went searching on TechNet for it.

How it works…

The Get-Help cmdlet in PowerShell can be used with virtually any command in order to find out more information about that particular function. I often use it when the specific name of a cmdlet that I want to use escapes my memory. By using Get-Help as a search function, it will present a list of available cmdlets that include the keyword you specified. This is a brilliant addition to PowerShell, and makes it so much more powerful than Command Prompt.

Also included with the Get-Help files are all of the special syntax and parameter options for each cmdlet that you might be working with. This saves you having to go to the Web in order to search for these functions, and it is just way more fun doing it at the command line than in a web browser.

Left arrow icon Right arrow icon

Key benefits

  • Get the first book on the market to unleash the power of Windows Server 2016, which improves the lives of thousands of enterprise users
  • Be the first to leverage the advent of Containers and Nano Server on Windows Server 2016, which utilizes the resources efficiently and increases productivity.
  • This practical, recipe-based approach helps you to delivering global-scale cloud services into your infrastructure using Windows Server 2016

Description

This hands-on Cookbook is stuffed full of practical recipes that will help you handle the essential administrative tasks in Windows Server 2016. You’ll start by familiarizing yourself with the look and feel of Windows Server 2016, and will then learn how to navigate through some daily tasks using the graphical interface. You will see how to compose optimal Group Policies and facilitate task automation with PowerShell 5.0 scripting. We will also take a look at the functions available to provide remote network access to your traveling users, and explore the much anticipated Nano Server and Hyper-V built-in integration support that is brand new in Windows Server 2016. By the end of this book, you will know how to take your Windows Server 2016-powered server and turn it into any common infrastructure role that might be required in your company.

Who is this book for?

This book is for system administrators and IT professionals with experience in Windows Server 2012 R2 environments who are looking to acquire the skills and knowledge necessary to manage and maintain the core infrastructure required for a Windows Server 2016 environment.

What you will learn

  • Build the infrastructure required for a successful Windows network
  • Navigate the new Server 2016 interface efficiently
  • Implement solid networking and security practices into your Windows Server environment
  • Design your own PKI and start issuing certificates today
  • Explore the brand-new Nano Server functionality
  • Enable nested virtualization on Hyper-V and Server
  • Connect your remote laptops back to the corporate network using Microsoft s own remote access technologies, including DirectAccess
  • Provide a centralized point for users to access applications and data by configuring Remote Desktop Services
  • Compose optimal Group Policies
  • Facilitate task automation with PowerShell 5.0 scripting

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 21, 2016
Length: 494 pages
Edition : 1st
Language : English
ISBN-13 : 9781785882999
Vendor :
Microsoft
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Nov 21, 2016
Length: 494 pages
Edition : 1st
Language : English
ISBN-13 : 9781785882999
Vendor :
Microsoft
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 197.97
Windows Server 2016 Cookbook
$65.99
Mastering Windows Server 2016
$65.99
Windows Server 2016 Hyper-V Cookbook
$65.99
Total $ 197.97 Stars icon
Banner background image

Table of Contents

12 Chapters
1. Learning the Interface Chevron down icon Chevron up icon
2. Core Infrastructure Tasks Chevron down icon Chevron up icon
3. Security and Networking Chevron down icon Chevron up icon
4. Working with Certificates Chevron down icon Chevron up icon
5. Internet Information Services Chevron down icon Chevron up icon
6. Remote Access Chevron down icon Chevron up icon
7. Remote Desktop Services Chevron down icon Chevron up icon
8. Monitoring and Backup Chevron down icon Chevron up icon
9. Group Policy Chevron down icon Chevron up icon
10. File Services and Data Control Chevron down icon Chevron up icon
11. Nano Server and Server Core Chevron down icon Chevron up icon
12. Working with Hyper-V Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(2 Ratings)
5 star 50%
4 star 0%
3 star 0%
2 star 50%
1 star 0%
Daniel B. Dec 09, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Started reading it and already finding the recipes useful. Hands on...
Amazon Verified review Amazon
Amazon Customer Jul 28, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Thick book due to big fonts, pictures and lots of empty white space per page. Very little detail. Not for IT pros needing in depth info on 2016. Im hoping "Server 2016 Unleashed" will be better when released.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.