• 12 heures
  • Moyenne

Ce cours est visible gratuitement en ligne.

course.header.alt.is_video

course.header.alt.is_certifying

J'ai tout compris !

Mis à jour le 01/06/2022

Administer Your Server Using PowerShell

In this chapter, you will learn about the various features that PowerShell offers. This software and scripting language provides a command-line environment similar to a shell in the Unix/Linux world, allowing you to perform all administration tasks in command-line mode without needing a GUI that eats up lots of processor and memory resources. 

Understand PowerShell

Before turning our backs on the GUI, let’s practice with Windows Server Standard that has a complete user experience, using the ready-installed PowerShell ISE.

First, navigate to the Start menu and find Windows PowerShell ISE. After a few moments, the following window should open:

PowerShell ISE
PowerShell ISE

When you first open PowerShell ISE, you’ll see a shell (in blue) and a command zone listing all of the PowerShell commands supported by your system (Get-Volume, Enable-LocalUser, Set-StoragePool, and Get-DnsClientCache).

You can type in commands or go to the right-hand panel to get more information about a command.

The Get-Volume command
The Get-Volume command

You can also bring up an additional panel that lets you test commands before putting them all together in a PowerShell script (with the .ps1 extension):

Complete ISE
Complete ISE

Let’s try the scripting language by testing a few integrated commands that are easy to run. The first commands useful for managing a server are those for adding features or roles.

Adding a Telnet client feature using PowerShell
Adding a Telnet client feature using PowerShell

One practical command is  Get-WindowsFeature  , which can be applied to all accessible servers or just the local one. It’s also possible to apply a filter to which results are shown, like here where we’re only showing installed features:

Showing installed features on the server SRVWDSCHI01
Showing installed features on the server SRVWDSCHI01

To run the script, click on the green play button, and the result will be displayed in the shell section.

Use Existing Scripts

Like the Unix/Linux world, one of the key strengths of PowerShell is its community! You’ll find many ready-made scripts created by administrators or technicians who want to save time to focus on system engineering or network tasks, or free up time to increase security across their stock.

For instance, you can find scripts for checking the health of your Active Directory and have an email report of the items retrieved by PowerShell. How handy is that?

Understand Desired State Configuration (DSC)

In addition, there are several PowerShell scripts from Microsoft and the community that you can use to configure a server. For example, you can ensure that the configuration is frozen, giving you a precise desired state configuration. These scripts, grouped under PowerShell DSC, are a new and helpful feature for setting state configuration.

You do this by declaring a target configuration in the scripts.

You’ll be able to manage your configuration using scripts and even version these configurations. You don’t have to directly administer a server but rather declare the configuration and let the PowerShell DSC engine apply the modifications. 

Again, the community will help you, as lots of desired configurations have been described and made available.

Let’s say you want to manage an Active Directory. Launch the command  find-module -name *AD*  . The first thing you’ll notice is that your ISE will ask you to install NuGet.

This lets you search for modules online on the PSGallery.

Next, you’ll have a list of all modules that meet the criteria you’ve entered. For instance, you’ll find the xActiveDirectory module, which you can use to manage an AD in the command line.

Thanks to these scripts, it’s now possible to move towards a core distribution without a GUI. You can manage your servers through PowerShell and use desired states to guarantee that your servers are correctly configured.

It allows you to prepare for your transition to the Cloud, enabling you to configure a complete architecture through APIs in just a few lines of script!

Additional Resources

Let’s Recap!

  • Windows Server has an ISE, an integrated script environment that simplifies PowerShell.

  • You can use PowerShell to launch commands to the operating system in text mode without using a GUI.

  • Thanks to the many PowerShell scripts, you don’t have to use a GUI, thereby increasing available resources, especially in a Cloud environment.

  • It is possible to describe a configuration and be sure of its application through PowerShell DSC, allowing you to deploy servers, or even groups of servers, solely on the command line.

In the next chapter of this course, you’ll learn to virtualize your servers using the Windows virtualization tool: Hyper-V.

Exemple de certificat de réussite
Exemple de certificat de réussite