Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:29:55+00:00 2026-05-22T21:29:55+00:00

I’m looking for a way to go through all binding settings already configured in

  • 0

I’m looking for a way to go through all binding settings already configured in my IIS.

Im using this to work with the IIS in Powershell:

Import-Module WebAdministration

So far I was able to get the main required information i want:

$Websites = Get-ChildItem IIS:\Sites

My array $Websites is filled correctly and with the following command…

$Websites[2]

..I recieve this result:

Name         ID   State    Physical Path       Bindings    
----         --   -----    -------------       --------------     
WebPage3      5            D:\Web\Page3        http  *:80:WebPage3  
                                               https *:443:WebPage3

Now here’s the part I having a hard time with:

I want to check if the binding is correct. In order to do that I only need the binding. I tried:

foreach ($site in $Websites)
{
    $site = $Websites[0]
    $site | select-string "http"
}

Debugging that code shows me that $Site doesn’t contain what I expected: “Microsoft.IIs.PowerShell.Framework.ConfigurationElement”. I currently have no clue how to explicitly get to the binding information in order to to something like this (inside the foreach loop):

 if ($site.name -eq "WebPage3" -and $site.Port -eq "80") {
    #website is ok    
 } 
 else {
    #remove all current binding
    #add correct binding
 }

Thank you for your help!


Solution:

Import-Module WebAdministration
$Websites = Get-ChildItem IIS:\Sites
foreach ($Site in $Websites) {

    $Binding = $Site.bindings
    [string]$BindingInfo = $Binding.Collection
    [string]$IP = $BindingInfo.SubString($BindingInfo.IndexOf(" "),$BindingInfo.IndexOf(":")-$BindingInfo.IndexOf(" "))         
    [string]$Port = $BindingInfo.SubString($BindingInfo.IndexOf(":")+1,$BindingInfo.LastIndexOf(":")-$BindingInfo.IndexOf(":")-1) 

    Write-Host "Binding info for" $Site.name " - IP:"$IP", Port:"$Port

    if ($Site.enabledProtocols -eq "http") {
        #DO CHECKS HERE     
    }
    elseif($site.enabledProtocols -eq "https") {
        #DO CHECKS HERE
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:29:56+00:00Added an answer on May 22, 2026 at 9:29 pm

    I don’t know exactly what you are trying to do, but I will try. I see that you reference $Websites[2] which is webPage3.
    You can do it like this:

    $site = $websites | Where-object { $_.Name -eq 'WebPage3' }
    

    Then when you look at $site.Bindings, you will realize that you need the Collection member:

    $site.bindings.Collection
    

    On my machine this returns this:

    protocol                       bindingInformation
    --------                       ------------------
    http                           *:80:
    net.tcp                        808:*
    net.pipe                       *
    net.msmq                       localhost
    msmq.formatname                localhost
    https                          *:443:
    

    And the test might then look like this:

    $is80 = [bool]($site.bindings.Collection | ? { $_.bindingInformation -eq '*:80:' })
    if ($is80) {
        #website is ok    
    } else {
        #remove all current binding
        #add correct binding
     }
    

    I sent content of Collection to pipeline and filtere only objects where property bindingInformation is equal to desired value (change it). Then I cast it to [bool]. This will return $true if there is desired item, $false otherwise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.