I figured I'd mention you could do it in one command with select-string...
select-string '^(?!#)' file.txt
<techstarts@xxxxxx> wrote in message
news:a852e49f-3c62-4dc2-b41c-9c3d0587ffad@xxxxxx
> I have below file called servers.txt
> --------------------------------------------------------
> #Hostnames should be lower caps
> Server1
> Server2
> Server3
> #Server4
> Server5
> ----------------------------------------------------------
> I would like to put some comment in the text file which powershell
> should skip it. is it possible. e.g. I do not want powershell to read
> anything which starts with #
>
> Thank you in Advance