Hi all I am trying to remove $BPVM from $BPVMS array if a condition is false, after the line $completed--. The idea is to keep checking a computer to see if an application is installed, if its not it will wind down a list to 0, once the count is zero the do loop terminates. I am unable to achieve the desired reults. I have tried filtering the array and then using % {$_.delete() but that doesnt work. It errors. Unless there is a better way of doing this? Please help
$Completed = $BPVMs.count
do {
Foreach ($BPVM in $BPVMs) {
Write-Host -ForegroundColor cyan "Checking for Blue Prism Installation on" $BPVM.name
if (Get-CimInstance -ComputerName $BPVM.name win32_product | Where-Object {$_.name -eq "Blue Prism"} | Select Name){
Write-Host -ForegroundColor green "True"
}Else{
Write-Host -ForegroundColor Red "False"
$Completed--
}
Write-Host -ForegroundColor red "There are" $Completed "VMS remaining"
}
}Until ($Completed -eq 0)