Reputation: 176
I'm currently playing around with PowerShell, but I've come across a bit of a brick wall regarding calculated properties and arrays, for example, I'm using the Web Administration / IIS module currently:
Get-Website |
? { $_.State -eq "Stopped" } |
select Name, @{ n = "Binding"; Expression = { $_.Bindings | select [string]::Join(", ", $_.Collection) } } |
ConvertTo-Html > "C:\iis.html"
The script is supposed to grab all currently off sites, and out put the site name and it's bindings to HTML. The issue is with the expression part of the calculated property to grab the bindings - it pipes the bindings collection (which is an array) to be joined by a string.Join() call. This works - but the output comes out like this:
@{ [string]::Join(", ", $_.Collection) =http *:80:blueberryboat.local, http *:80:test.co.uk}
Any ideas?
Cheers
Upvotes: 1
Views: 1233
Reputation: 8650
Interesting syntax... but that's not correct way to do that. how about:
Expression = { $_.Bindings | Foreach-Object { $_.Collection -join ', ' }}
Upvotes: 2