Conditional Where Clause in Powershell
Switching between ‘match‘ and ‘eq‘ in a where clause, depending on a variable:
1 2 3 4 5 6 7 |
$Certs = @(Get-ChildItem -Recurse -Path Cert:\LocalMachine | ?{ if($SearchExact){ $_.Subject -eq "CN=$CertDomain" }else{ $_.Subject -match "CN=.*$CertDomain" } }); |