Forum Discussion
rexParthi
Aug 16, 2023Copper Contributor
I am unable to add multiple condition ps where-object
I am unable to add multiple condition where-object, getting error when add -and condition The below one works foreach($l in (gci -Path .\ -Filter *.xlsx))
{
if (
(Import-Excel -Path $l.Name|Whe...
rexParthi
Aug 16, 2023Copper Contributor
I got the issue
it is becase of the () in the where condition it should be {} to use -and for adding different property
foreach($l in (gci -Path .\ -Filter 345-ASSIGNMENT_NOT_COMPLETED*.xlsx)){
if ( (Import-Excel -Path $l.Name|Where-Object {$_.message_id -EQ '491582638558019584' -and $_.action -eq 'delete'} ).count -gt 0)
{Write-Host $l.Name}
}