Powershell script to export IIS website details [Answered]RSS

2 replies

Last post Dec 22, 2015 11:25 AM by Mateiash

  • Powershell script to export IIS website details

    Nov 16, 2015 03:40 AM|aurigomsdn|LINK

    <div class="post-text" itemprop="text">


    I need to extract all the website details created in our IIS server with the following details. As we have more than 80 sites created in our IIS server, I am searching for an easier way to export these details.

    details required :

    • Website Name
    • Bindings
    • State
    • DB Server name [mapped in connection string]
    • DB Name [mapped in connection string]

    I am able to extract all the details except DB related available in connection strings using get-website cmdlet. Requesting your help if you know any better way to extract all the information under single file.



  • Re: Powershell script to export IIS website details

    Nov 16, 2015 10:04 PM|Pengzhen Song - MSFT|LINK


    You can try using get-webconfiguration and get-webconfigurationproperty cmdlets to get connection string and then extract DBname. For more information, please refer to the document:



    And the similar discussion:

    Import-Module WebAdministration
    Get-WebApplication | `
    ForEach-Object {
    $webConfigFile = [xml](Get-Content "$($_.PhysicalPath)\Web.config")
    Write-Host "Web Application: $($_.path)"
    foreach($connString in $webConfigFile.configuration.connectionStrings.add)
      Write-Host "Connection String $($connString.name): $($connString.connectionString)"
      $dbRegex = "((Initial\sCatalog)|((Database)))\s*=(?<ic>[a-z\s0-9]+?);"
      $found = $connString.connectionString -match $dbRegex
      if ($found)
       Write-Host "Database: $($Matches["ic"])"
    Write-Host " "


    Hope it can help you.

    We are trying to better understand customer views on social support experience. Click HERE to participate the survey.
  • Re: Powershell script to export IIS website details

    Dec 22, 2015 11:25 AM|Mateiash|LINK

    I have 360 Websites on my IIS, and when I am trying to export to a file (txt or csv), I have just 220 websites listed

    There is a buffer limit for appcmd.exe command?