9951 explained code solutions for 126 technologies


powershellHow to filter a list of strings by specific text included in string


@("TestAccount","MainCorporate","EnterpriseAccountTest","Tester1","Tester2") | Where-Object{$_ -ilike "*Test*"}ctrl + c
@("TestAccount","MainCorporate","EnterpriseAccountTest","Tester1","Tester2")

create an array of preloaded strings

Where-Object

filter list of enumerated data based on a condition

{$_ -ilike "*Test*"}

retrieves the $_ iterator object for the list of strings and performs a case-insensitive match for text including the string Test in the middle of the string