You are using the wrong comparison operator.
-contains checks if a Collection(array\list\etc) contains one specific element.
@('Z', 'A', 'Q', 'M') -contains 'A' returns $true
But you are working with the single strings of the array: you therefore need to use either -like(for simple wildcard matching) or -match(for regular expression matching)
so ($env:path).split(';') | Where-Object { $_ -match 'bin' }
Also, in more powershell-y way $env:path -split ';' | Where-Object { $_ -match 'bin' }
EDIT: and this is to go even further beyond! $env:path -split ';' -Match 'bin' (thanks @iRon)
(note I made the matching as simple as possible as example, you'll need to test if it works correctly for your needs)
More about Comparison Operators
-containsis for an exact match on items of an array. what you want here is-match "bin"or-like "*bin*".($env:path).split(";") | Where-Object {$_.contains("bin") }if you are looking for the C# string.contains() method$env:path.split(";") -match 'bin'-contains/-notcontainsare collection operators: they test if the LHS object is equal in full to at least one element of the RHS collection. They are not to be confused with the.Contains().NET method for substring matching. While PowerShell has no equivalent operator for literal substring matching, you can use-likewith wildcard expressions or-matchwith regular expressions, both of which are case-insensitive by default.