I'd like to add a new property to an array of objects. Add-member doesn't work, please assist
$computers = Get-ADComputer -Filter {(name -like "SMZ-*-DB")} | select -First 30
workflow test-test
{
param([Parameter(mandatory=$true)][string[]]$computers)
$out = @()
foreach -parallel -throttlelimit 20 ($computer in $computers)
{
sequence
{
[bool]$ping = (Test-Connection $computer.name -Quiet -Count 1)
$computer = $computer | Add-Member -NotePropertyName "Ping" -NotePropertyValue $ping
$Workflow:out += $computer
}
}
return $out
}
test-test $computers
You can do something like this in powershell 7. It looks like the ADComputer objects from Get-ADComputer are read-only, so you can't add members to them.