Major error in WIN 7 64 enterprise

from CMD:

powershell -nologo -noprofile -command "get-process | sort-object Id | cat "

Causes major issues with the operating system... WHY?

error
KonfigurationKingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KonfigurationKingAuthor Commented:
there is also a beeping noise coming from my computer.
0
footechCommented:
Well, I don't have an answer as to why (it's an interesting question), but I do have to ask why you would want to run that command?  Or was it just a mistake you ran across while writing a script?
0
KonfigurationKingAuthor Commented:
I am trying to learn how to write scripts ... I am curretnly reading windows powershell 2.0 microsoft press
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

simon3270Commented:
The problem is that you are trying to display binary data on the screen - this will produce the characters you see, and the beeping (probably when it tries to display a byte with the value 7).

Try the individual commands interactively in powershell, to see what the output looks like.  Only when you are happy that you are displaying the right text should you try to script it.
0
simon3270Commented:
The first two commands work as expected - get-process returns a process list table, then sort-object sorts it on the specified column (Id).  The problem is the "cat".

"cat" in powershell is an alias for "get-object", which gets an object specified as an argument and writes it to the output.  So, for example,
    cat my_file.txt
will display the contents of my_file.txt.  So far, it is like the UNIX "cat" command.  Problems start when you specify just
    cat
as a command (as you do in your pipeline.  It seems just to produce a seemingly neverending list of error messages, or repeatedly outputs its  input.

So,
    powershell -nologo -noprofile -command "get-process | sort-object Id"
will list processes as you wanted.  The "cat" is not required.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
footechCommented:
I thought about this a bit last night.  Get-Content (cat) retrieves the contents of a file.  If you open an executable file with Notepad (or some other text viewer) you'll see something similar.  The reason your command produces output (even if it's strange-looking) and doesn't just error out is because Get-Process outputs objects with a scriptproperty called "path", and Get-Content has a path parameter which accepts pipeline input.  So basically what you're doing is telling Get-Content to read the content of every file in the process list.  You'll see the same behavior if you just run
gc c:\pathTo\someExecutable.exe
As to the beeping, simon3270's explanation seems correct.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.