I found one solution:
((dir resources).Name | select-string Windows | out-string).Trim()
out-string
converts an input from another command to a string, and Trim()
is a function that only works on strings (i.e., Trim()
won't work on the output of a command that returns some non-string type).