Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

can't use "find.exe" in powershell

1,060 views
Skip to first unread message

freddy chavez

unread,
Jul 22, 2007, 10:35:45 PM7/22/07
to
Hi guys. Every time I try to use "find.exe" in powershell it says:

netstat -an | find "ESTABLISHED"
FIND: Parameter format not correct

I've tried in many ways and I always get the same.
Thanks for your help.

Regards,
Freddy Chavez.


Keith Hill

unread,
Jul 22, 2007, 10:49:23 PM7/22/07
to
"freddy chavez" <freddyc...@hotmail.com> wrote in message
news:us1rhINz...@TK2MSFTNGP04.phx.gbl...

> Hi guys. Every time I try to use "find.exe" in powershell it says:
>
> netstat -an | find "ESTABLISHED"
> FIND: Parameter format not correct
>

I would use PowerShell select-string cmdlet to "select" strings from an
array of input strings e.g.:

netstat -an | select-string "established"

If you are really bent on using find.exe, try this:

netstat -an | find.exe `"Established`"

I think what is going on is that PoSh is consuming the double quotes and not
passing them to find.exe.

--
Keith

osmans...@gmail.com

unread,
Jul 23, 2007, 8:42:48 AM7/23/07
to

You better use FINDSTR command.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=881257&SiteID=1


Keith Hill yazd :

Matthias Tacke

unread,
Jul 23, 2007, 10:20:14 AM7/23/07
to
Why?
Find and findstr share the need of escapimg the qoutes in PoSh.
In a cmd shell they both have their advantages and shortcomings and so are
IMO needed both.
In a new evironment like PoSh you should switch to select-string even if
some tasks require a lot less typing with findstr (esp. the /G option)

--
Greetings
Matthias

Jacques Barathon [MS]

unread,
Jul 23, 2007, 10:45:03 AM7/23/07
to
"Matthias Tacke" <Matt...@Tacke.de> wrote in message
news:f82kfu...@news.tacke.de...

Not such a big difference:

C:\> dir *.log | findstr /g:errorcodes.txt

vs

PS> dir *.log | select-string (get-content errorcodes.txt)

Not mentioning that you can use aliases to reduce the typing. Select-string
doesn't have one by default, get-content has gc, type and cat.
Performance-wise I haven't tested this syntax with large files but I suspect
that you might see an improvement if you assign errorcodes.txt to a variable
first, which slightly increases the typing but not that much.

Jacques

Matthias Tacke

unread,
Jul 23, 2007, 1:31:37 PM7/23/07
to
Jacques Barathon [MS] wrote:
...

> PS> dir *.log | select-string (get-content errorcodes.txt)
>
> Not mentioning that you can use aliases to reduce the typing.
> Select-string doesn't have one by default, get-content has gc, type and
> cat.
> Performance-wise I haven't tested this syntax with large files but I
> suspect that you might see an improvement if you assign errorcodes.txt
> to a variable first, which slightly increases the typing but not that much.
>

Thanks for the hint Jacques,
since I'm quite new to PoSh I'm still searching for ways to condense code
and I'm baffled whenever the pro's here do a contest ;-)

--
Greetings
Matthias

freddy chavez

unread,
Jul 23, 2007, 3:03:05 PM7/23/07
to
> since I'm quite new to PoSh I'm still searching for ways to condense code
> and I'm baffled whenever the pro's here do a contest ;-)

I feel the same way. Thanks to all.

Regards,
Freddy Chavez.


Kiron

unread,
Jul 24, 2007, 2:51:11 AM7/24/07
to
You can also use 'namespace variable notation' to load contents of a file,
not recommended for files -lt a few MB.

dir *.log | select-string {c:errorcodes.txt}

--
Kiron

Kiron

unread,
Jul 24, 2007, 2:57:26 AM7/24/07
to
Excuse the typo:
...not recommended for files -gt a few MB.

Kiron

unread,
Jul 24, 2007, 4:01:34 AM7/24/07
to
Sorry late night here.

--
Kiron

Kiron

unread,
Jul 24, 2007, 4:03:58 AM7/24/07
to
Sorry late night here, let me try again...

You can also use 'namespace variable notation' to load contents of a file,

not recommended for files -gt a few MB.

dir *.log | select-string ${c:errorcodes.txt}

--
Kiron

0 new messages