Installing IIS

Before you can use IIS, you must install it onto your host. Like other roles and features of Windows Server 2019 that are covered in this book, you install IIS by using the Install-WindowsFeature cmdlet. Once you have installed the web server, you can take a look at the host.

Getting ready

This recipe uses SRV1 and assumes a fresh installation. If you have used SRV1 to test previous recipes, you may need to remove the Web-Server feature before you run this recipe. Also, you should have the Windows Server 2019 installation DVD in the D: drive of SRV1.

How to do it…

  1. Add the Web-Server feature, sub-features, and tools to SRV1, as follows:
    $FHT = @{
      Name                  = 'Web-Server'
      IncludeAllSubFeature   = $true
      IncludeManagementTools = $true
      Source                 = "D:sourcessxs"
    }
    Install-WindowsFeature  @FHT
  2. See what features are installed:
    Get-WindowsFeature -Name Web*  | Where-Object Installed
  3. Check the IIS administration modules:
    $Modules = @('WebAdministration', 'IISAdministration')
    Get-Module -Name $Modules -ListAvailable
  4. Get a count of how many commands are in each module:
    $C1 = (Get-Command -Module WebAdministration |
            Measure-Object |
              Select-Object -Property Count).Count
    $C2 = (Get-Command -Module IISAdministration |
            Measure-Object |
              Select-Object -Property Count).Count
    "$C1 commands in WebAdministration Module"
    "$C2 commands in IISAdministration Module"
  5. Get details of the IIS provider contained in the WebAdministration module:
    Import-Module -Name WebAdministration
    Get-PSProvider -PSProvider WebAdministration
  6. You can find out what is in the IIS: drive with the following command:
    Get-ChildItem -Path IIS:
  7. You can find out what is in the Sites folder with the following command:
    Get-Childitem -Path IIS:Sites
  8. Look at the default website, as follows:
    $IE  = New-Object -ComObject InterNetExplorer.Application
    $URL = 'HTTP://SRV1'
    $IE.Navigate2($URL)
    $IE.Visible = $true 

How it works…

In step 1, you use the Install-WindowsFeature cmdlet to install IIS, as well as a number of the web server sub-features and management tools, which look like this:

How it works…

In step 2, you use the Get-WindowsFeature cmdlet to retrieve the web server related features installed on SRV1, the output for which looks like this:

How it works…

In step 3, you get the IIS-related modules on SRV1, which produces the following output:

How it works…

In step 4, you get a count of the number of commands in the WebAdministration and IISAdministrtion modules, as follows:

How it works…

In step 5, you import the WebAdministration module, which loads the IIS provider. Then you get details of the provider, as follows:

How it works…

In step 6, you use the provider to view the contents of IIS:, which looks as follows:

How it works…

In step 7, you view the contents of IIS:Sites, which looks like this:

How it works…

In step 8, you use Internet Explorer to view the web service on SRV1, which looks like this:

How it works…

There's more...

In step 1, you installed the IIS management tools. These tools include the IIS GUI tool, plus the WebAddministration and IISAdministration PowerShell modules.

In step 5, you import the WebAdministration module manually. In addition to loading the cmdlets/functions contained in the module, when you import the module, PowerShell loads the WebAdministration PowerShell provider. This provider enables you to browse aspects of the web server, including the sites, application pools, and SSL bindings on the host. You use this feature in later recipes in this chapter. When you use any of the cmdlets in the WebAdministration module, PowerShell, by default, auto-loads the module. But if you only want to use the provider, you have to manually load the module first, as shown in this recipe.

In step 8, you view the default website that the installation process adds for you. Browsing to the server is a great way to determine that IIS is loaded and is running on SRV1.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.239.123