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.
..................Content has been hidden....................

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