Microsoft IIS 10.0 – IIS administration with PowerShell cmdlets

How to enable Remote Desktop on Windows Server 2019

In this recipe, we will log in to the different PowerShell remote-management modules for Nano Server to manage IIS Server. We will log in through Server Manager to PowerShell, and we will also review the PowerShell remote script.

Getting ready

In this recipe, we are going to access Nano Server through PowerShell and the IISAdministrator module. You will need a Windows Server 2016 virtual or physical instance for remote PowerShell management of 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 at the IP 172.16.15.60 and on the server named WIN2016IIS.
  2. Open Server Manager and click on All Servers:
  1. Go to the Manage menu in Server Manager and open Add servers. The Add servers option will add your remote server and can be managed with Windows Server 2016 Server Manager. Once we click on Add Servers, you will get the Add Servers window:
  1. You can add a remote server with three different options. Active Directory searches for the computer name and DNS searches for either the name or IP address and Imports the computer (server) name and IP if you have one or more than one server. Select the DNS tab and add the Nano Server IP. If you have DNS set up, it will get resolved to the server name. If you don’t have DNS settings configured in Nano Server, it will give you a warning. Ignore the warning and press OK, as shown here:
  1. In the All Servers window, we have added the IP 172.16.15.63, which is our Nano Server 2016 IP. Now right-click on the Nano Server IP, 172.16.15.63, and click on Manage As…. It will open a new authentication window called Windows Security for Nano Server, as shown here:
  1. Provide the username localhost\administrator and administrator password and press OK. I’ve also selected the Remember me option, which will remember the administrator username and password.
  2. Now come back to the Server Manager page. You can see that it’s authenticated with Nano Server:
  1. Here you can see that we’ve added a server called Nano with IP address 172.16.15.63. Now let’s move on to access PowerShell.
  2. Right-click on Nano Server, which is listed in the Server Manager window. You will get a popup. Click on the PowerShell option, and it will again ask you the administrator username and password for Nano Server:
  1. Type the Nano Server username and password. Click on OK to see PowerShell get connected with Nano Server remotely without a script:
  1. You get remotely connected to Nano Server PowerShell. Next, you we have to test some of the commands. We have to first use the import-module iisAdministration to use of IIS administration. Once the IISAdministration module is imported, we can write any IIS command and it will work.
  2. Use the PowerShell command Get-IISsite. You can see that it will bring you all listed sites in the Nano Server IIS instance. You can write more commands through PowerShell.
  3. We have one more option for the flexible use of PowerShell scripts, PowerShell ISE. Let’s check how we can open it and what the benefits of it are.

 

 

  1. Go to the WIN2016IIS server to connect to Nano Server 2016 through PowerShell. You have to first log in to the WIN2016IIS server (any Windows Server 2016 or Windows 10 machine will do). We will use PowerShell to remotely connect to Nano Server at 172.16.15.63.
  2. Now press Windows + R. You will get the Run window. Open PowerShell ISE with administrative rights, type the command RunAs /user:Administrator PowerShell_ISE.exe, and press OK. Now it will ask you the administrator password for your Windows Server 2016 instance. Type the administrator password and press Enter. Now you should get the PowerShell window, as shown here:
  1. We performed this step earlier in Chapter 7, Deploying IIS 10.0 on Nano Server. Here we just have to recap. You can that see we have several easy options available in PowerShell ISE. Using the Script Editor, we can write our script and it will also show you the advanced automation writing option. You can save and use it several times. We have Commands, which displays available commands in PowerShell and available PowerShell module features. You can open the simple PowerShell prompt, which is available in Windows Server; if you need administrative privileges with PowerShell ISE, you’ll need the administrator username and password to access PowerShell ISE. Once you are accessing Nano Server remotely, make Nano Server a trusted host, and then get connected to it with the proper username and password.

How it works…

In this recipe, we opened Server Manager on the WIN2016IIS server and added the Nano Server host to the All Servers list. We then authenticated Nano Server with Server Manager and opened PowerShell remote management for Nano Server to manage IIS Server. We logged in through Server Manager to PowerShell, imported the IISAdministration module, and ran the Get-Site command. Also, we reviewed the PowerShell ISE remote script.

Comments are closed.