The Get-IIS cmdlet in PowerShell gets the IIS websites. You can specify the Name parameter to get IIS site information like the IIS website name, physical path, and bindings.
Internet Information Server (IIS) is a free, flexible, and Windows Operating System webserver to host websites and provides internet-based services.
IIS server manages a list of websites and app pools. Most often system administrator manages IIS routine tasks to get a list of websites hosted on the IIS web server, get all IIS bindings and SSL certificates list. Using PowerShell, all these tasks can be easily automated.
Using the PowerShell Get-IISSite cmdlet, you can easily get list of websites in IIS. PowerShell IISAdministration module offers better support for the pipeline and contains many cmdlets to efficiently manage the IIS web server.
In this article, I will explain to you how to get list of websites hosted in IIS with step-by-step examples.
- IIS 10.0 Windows Features enabled and installed
- PowerShell 5.1 or PowerShell 6+ version
- IISAdministration module installed
Assuming, you have a minimum version of PowerShell and IIS10.0 windows feature enabled.
Let’s start with the installation of the PowerShell IISAdministration module
Installation of IISAdministration module
Open PowerShell console or PowerShell ISE with elevated ( run as administrator) mode and run below command
PS C:\> Install-Module -Name 'IISAdministration'
The above command will install the IISAdministration module
Cool Tip: Do you know how to print environment variables in PowerShell!
PowerShell – IIS Get List of Websites
Get-IISSite cmdlet in PowerShell gets iis websites and their key information.
Get List of websites in IIS Server
To get a list of websites hosted in the IIS server, run the following command
PS C:\> Get-IISSite
Above Get-IISSite command in PowerShell, get list of websites hosted in IIS web server.
The get-IISSite command also gets website details such as
- Website name
- Website Status
- Website Physical Path
- IIS bindings for Website
Display information about IIS website
To get information about a particular IIS website, use the Name parameter and provide the website name as a string.
PS C:\> Get-IISSite -Name 'TestHMI' Name ID State Physical Path Bindings ---- -- ----- ------------- -------- TestHMI 2 Started C:\inetpub\wwwroot\TEST HMI http *:1001: PS C:\>
In the above example, the Get-IIS command gets all configuration and key parameters like IIS website status, IIS website Physical Path, and IIS website bindings.
Cool Tip: Do you know how to enable psremoting for remote commands in PowerShell!
I hope you may find the above article about how to get list of websites from IIS using PowerShell useful and educational.
Using the Get-IISSite cmdlet, you can easily query the IIS webserver to get a list of IIS websites and configuration details about websites like website name, IIS website status, IIS website Physical Path and IIS website bindings information.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.