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.
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
.
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
Get-WindowsFeature -Name Web* | Where-Object Installed
$Modules = @('WebAdministration', 'IISAdministration') Get-Module -Name $Modules -ListAvailable
$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"
WebAdministration
module:Import-Module -Name WebAdministration Get-PSProvider -PSProvider WebAdministration
IIS:
drive with the following command:Get-ChildItem -Path IIS:
Sites
folder with the following command:Get-Childitem -Path IIS:Sites
$IE = New-Object -ComObject InterNetExplorer.Application $URL = 'HTTP://SRV1' $IE.Navigate2($URL) $IE.Visible = $true
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:
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:
In step 3, you get the IIS-related modules on SRV1
, which produces the following output:
In step 4, you get a count of the number of commands in the WebAdministration
and IISAdministrtion
modules, as follows:
In step 5, you import the WebAdministration
module, which loads the IIS provider. Then you get details of the provider, as follows:
In step 6, you use the provider to view the contents of IIS:
, which looks as follows:
In step 7, you view the contents of IIS:Sites
, which looks like this:
In step 8, you use Internet Explorer to view the web service on SRV1
, which looks like this:
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
.
18.191.239.123