#Get just website from excess output

12 messages · Page 1 of 1 (latest)

devout root
#

How do I get this script to output just the URL portion test1.desktop.com

$SearchISS = {
    $targetList = Get-PlatformTopology -environments $environment -IIS 1 -hostNameFilter $filter
    param($target)

    $sites = get-website
    foreach ($site in $sites) {
        $bindings = $site.bindings.Collection | Where-Object { $_.protocol -eq "https"} | Select-Object -ExpandProperty bindingInformation

        foreach ($binding in $bindings) {
                Write-Host $binding
        }
}
        
    foreach ($target in $targetList) {
        $hostName = $target.HostName
        Write-Host ''

        $session = Get-PowershellLegacySession -ComputerName $hostName

        Invoke-Command -Session $session -ScriptBlock $SearchIIS -ArgumentList $target
    }```
that outputs:
```*:443:test1.desktop.com
*:443:test2.desktop2.com```
broken drift
#

I wonder how your code works when the param block is not the first line in your scriptblock

devout root
#

so like move it around?

sullen lynx
#

He means it should start:

$targetList = Get-PlatformTopology -environments $environment -IIS 1 -hostNameFilter $filter
$SearchISS = {
    param($target)
...
#

But actually I think that $targetlist is meant to be below the end of $SearchISS

#

But honestly, the whole thing is confusing. You're passing -ArgumentList $target but not actually using that in the search script.

#

Anyway, you should be able to change: Write-Host $binding to $binding.host

#
$site.Bindings.Collection.Where{$_.protocol -eq "https"}.BindingInformation.Host
devout root
#

tried it word for word as well as powershell $bindings = $site.bindings.Collection | Where-Object { $_.protocol -eq "https"} | Select-Object -ExpandProperty bindingInformation.Host

devout root
#

would a substring indexOf work?