Get all website entries in IIS using Powershell
Published on: 6th Feb 2020
Updated on: 26th Jul 2025
Overview
The best part of using Powershell is that it is capable of managing features or services in a Windows server or desktop. If you are managing the multiple IIS through the GUI, you might have slidely different configuration in the appPool and the directory. But, this issue can be avoid by using Powershell script to setup the appPool and directory in all servers.s
In this blog post, we are going to see how to use the Powershell in managing IIS.
Explanation
The baby step, get the list of the website entries in IIS.
Import-Module WebAdministration
cd IIS:\Sites
Get-ChildItem | select name
Explanation:
-
We need to import the
WebAdministration
PS module. This module includes all the necessary API for Powershell to interact with IIS. -
The second line is to change the current location to the IIS Sites folder.
-
Finally, get all the items in the current location and show the name attribute of the object.
To list all websites and shows the common fields:
Import-Module WebAdministration
cd IIS:\Sites
ls
To find a website by its' name:
Import-Module WebAdministration
cd IIS:\Sites
ls | where name -like '*mywebsite*'
To view all website's fields:
Import-Module WebAdministration
cd IIS:\Sites
ls | select *
Notes
-
In case you want to write shorter code for
Get-ChildItem
, you may usels
(i.e., the alias ofGet-ChildItem
).Import-Module WebAdministration cd IIS:\Sites ls | select name
Related posts
- Restart IIS appPool with Powershell
- Setting up IIS server with Powershell
- View the binding for the website in IIS with Powershell
Back to #POWERSHELL blog
Back to #blog listing
Author
Lau Hon Wan, software developer.