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.
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
Keith Hill yazd :
--
Greetings
Matthias
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
> 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
I feel the same way. Thanks to all.
Regards,
Freddy Chavez.
dir *.log | select-string {c:errorcodes.txt}
--
Kiron
--
Kiron
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