Get all website entries in IIS
Published on: 6th Feb 2020
Updated on: 16th Jan 2022
Explanation
It's very easy to get the list of the website entries in IIS with 3 lines of code.
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.
Notes
- In case you want to write shorter code for
Get-ChildItem
, you may usels
(i.e., the alias ofGet-ChildItem
).
Jump to #POWERSHELL blog
Author
Lau Hon Wan, software developer.