Format Issue (those curly brackets!!) Listing IIS sites (IP and protocol)

Welcome Forums General PowerShell Q&A Format Issue (those curly brackets!!) Listing IIS sites (IP and protocol)

Viewing 4 reply threads
  • Author
    Posts
    • #227383
      Participant
      Topics: 9
      Replies: 16
      Points: 85
      Rank: Member

      Hi Folks

      I have a small PS script that will list all websites, and the IP it is bound too, and if it has a http or https binding.

      So, it should look like this:

      But instead it’s showing as

      My code is:

      I am splitting the bindings to get the first part of the bindings (i.e. the IP address) Nb. Our sites can have mulitple host headers but only 1 IP, so that’s the reason for the split – to just get first IP.

      But for the protocol, some sites are bound to IP and have a https binding as well, and others only a dedicated IP. So, to not show http, http, http, https – I tried to sort-object -Unique to just get one of each http and/or https etc.

      But I can’t get it show the protocol without the curly brackets! 🙁

      I know that they are added because it’s not just a string, but array of values…. but I thought there must be an easy way to display that without those curly suckers?!

      Thanks

      Alex

       

       

       

    • #227395
      Participant
      Topics: 9
      Replies: 707
      Points: 2,848
      Helping Hand
      Rank: Community Hero

      I think you’ll just need a line per protocol if you don’t want it to show the curly braces. As you said, it’s how powershell displays a nested group.

    • #227398
      Participant
      Topics: 10
      Replies: 2481
      Points: 6,543
      Helping Hand
      Rank: Community MVP

      But I can’t get it show the protocol without the curly brackets!

      That’s Powershells way to display an array. If you want to output a comma separated list of the array elements you can do it like this:

    • #227458
      Participant
      Topics: 9
      Replies: 16
      Points: 85
      Rank: Member

      Thanks Doug!

      Hey Olaf! Thanks…(again) ! You helped me a couple years back with PS/IIS stuff too! Always a pleasure to see your avitar help out on my questions!

    • #227467
      Participant
      Topics: 9
      Replies: 707
      Points: 2,848
      Helping Hand
      Rank: Community Hero

      Nicely done Olaf! It could also join with spaces but unfortunately “ n" "r” did not put it on additional lines.

      I learned something as well, thanks again.

Viewing 4 reply threads
  • The topic ‘Format Issue (those curly brackets!!) Listing IIS sites (IP and protocol)’ is closed to new replies.