Microsoft IIS 10.0 – Configuring IIS 10.0 websites on Nano Server

How to set a static IP address on Windows Server 2019

In this recipe, we will use PowerShell commands to recycle the v5mysite.com application pool. We will check the default Document Settings and listed page name and add the new filename to the default document, v5mysite.htm. We will make the changes in the physical path of the v5mysite.com website.

Getting ready

In this recipe, we are going to remote connect Nano Server through PowerShell and configure our website through the IISAdministrator module. You will require a Windows Server 2016 virtual or physical server for remote PowerShell management for Nano Server 2016. For all this installation and configuration work, you should have administrative privileges.

How to do it…

  1. Log in to Windows Server 2016 with the 172.16.15.60 and name WIN2016IIS. Press Windows + R on your keyboard, and you will get the Run window. Open PowerShell ISE with administrative rights, and type in the command RunAs /user:Administrator PowerShell_ISE.exe in the Run window, as shown here:
  1. Press OK. It will ask you the administrator password of your Windows Server 2016 instance (not Nano Server). Type the administrator password and press Enter. Now the PowerShell window will open.
  2. Now we have to remote connect to Nano Server 2016 at IP 172.16.15.63. Write the following command in PowerShell:

Enter-PSSession –ComputerName "172.16.15.63" -Credential ~\Administrator
  1. Now you will get a pop-up window for the Nano Server administrator username and password. Enter the administrator password and press OK to log in. You have successfully connected.
  2. Now let’s import the IIS Administration module. Write the command Import-module iisAdministration and press Enter. You will get the PowerShell module imported.
  3. Write the command Get-IISAppPool $sm = Get-IISServerManager $sm.ApplicationPools["NanoAPP"].Recycle() to recycle the application pool NanoAPP, as shown here:
  1. Once we run the command, we will get a list of application pools available in IIS on Nano Server, the PowerShell command will only recycle the application pool NanoAPP, and we’ll get its status as Started. We can use the start and stop commands $sm = Get-IISServerManager $sm.ApplicationPools["NanoAPP"].Stop() and $sm.ApplicationPools["NanoAPP"].Start() for the application pool, respectively. We can use these commands as and when we require.
  2. Now we are going to check the default document files list available in the Default Document settings. Write the command Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files" in PowerShell and press Enter, as shown here:
  1. We can now see that we have listed all available file names in IIS Server. Marked default.htm.
  2. Now we are going to create a file named v5mysite.htm in the Default Document settings. Write the command Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files" | New-IISConfigCollectionElement -ConfigAttribute @{"Value" = "v5mysite.htm"} and press Enter, and you will get the filename v5mysite.htm added to the Default Document.
  3. Now we are going to check whether v5mysite.htm is available in the Default Document. Run the command Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files", as shown here:
  1. You can see in the figure that we have created the entry for v5mysite.htm entry in the Default Document.
  2. Let’s change the existing physical path, C:\v5mysite, of the website v5mysite to the new physical path, C:\v5mysite-new. Run the following command:

Get-IISsite v5mysite
$manager = Get-IISServerManager
$manager.Sites["v5mysite"].Applications["/"].VirtualDirectories["/"].PhysicalPath = "C:\v5mysite-New"Get-IISsite v5mysite
  1. You can see in the figure that website v5mysite has the existing path C:\v5mysite. After running the PowerShell command, the physical path has changed to C:\v5mysite-New.
To recycle an application pool on demand, you may have to immediately recycle an unhealthy worker process instead of waiting for the next configured recycle. Rather than instantly stopping the worker process, which can cause service interruptions, you can use on-demand recycling specially when new settings/ changes are done that will sometimes not be replicated. After recycling, all running worker processes are restarted with the new changes of the application pool.

How it works…

In this recipe, we recycled the v5mysite.com application pool NanoAPP and checked the files listed in the Default Document. We added a new file called v5mysite.htm to the Default Document. We also changed the physical path of v5mysite.com.

Comments are closed.