How to get the default Documents from the IIS site using PowerShell?


To get the default documents stored on the IIS default website page, you can use the below command.

Example

Get-WebConfigurationProperty -Filter //defaultDocument/files/add
   -PSPath 'IIS:\Sites\Default Web Site' -Name value `
   | select value

Output

Value
-----
Default.htm
Default.asp
index.htm
index.html
iisstart.htm

To check if the Default document contains a specific file,

(Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:\Sites\Default Web Site' -Name value).value -contains 'iisstart.htm'

The above command checks if the IIS default website contains any iisstart.htm on the default document page.

You can also use another website instead of using 'Default Web site'. To get the default documents file at the IIS level,

(Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:\' -Name value).value 

Updated on: 18-Mar-2021

374 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements