To complement Kory Gill’s useful answer , which suggests that the problem may be that there are CRLF ( "`r`n") line endings in the input , in this case -split "`n"(splitting into LF only) will leave the resulting array elements with ending CR ( "`r"), resulting in "aa"not will be found using -contains, since the actual value "aa`r".
Windows Unix :
$a -split '\r?\n'
\r?\n ( ), LF (\n), (?), CR (\r).
\r \n PowerShell `r `n ( ).
, PowerShell , :
: [Environment]::NewLine , (-) : "`r`n" Windows, "`n" Unix- , , , , , .