Sometimes the output you get isn't quiet what you are looking for. Here is an example.
"My machine worked great this morning and started to slow down this afternoon."
So you go the machine and run:
Get-Process
You get a lot of information that could probably be better laid out for your quick troubleshooting. This is where select and sort are your friends.
select is an alias for Select-Object
sort is an alias for Sort-Object
First lets try:
Get-Process | Get-Member
This returns all the properties we have to choose from. Remember in PowerShell you are working with actual objects and that allows for a lot of properties and methods.
For now we will select name, starttime, and cpu:
Get-Process | select name, starttime, cpu
It still needs cleaned up so let's sort it:
Get-Process | select name, starttime, cpu | sort cpu
Better, but I don't really care about the processes using hardly any resources so we are going to flip the results by doing:
Get-Process | select name, starttime, cpu | sort cpu -Descending
Now with a quick glance we can see the biggest resource hogs and what time they started. Using select and sort can get you the preferred layout for your specific taste and purpose at the moment. Remember to use gm or Get-Member to find out what object properties are available to select from.
"My machine worked great this morning and started to slow down this afternoon."
So you go the machine and run:
Get-Process
You get a lot of information that could probably be better laid out for your quick troubleshooting. This is where select and sort are your friends.
select is an alias for Select-Object
sort is an alias for Sort-Object
First lets try:
Get-Process | Get-Member
This returns all the properties we have to choose from. Remember in PowerShell you are working with actual objects and that allows for a lot of properties and methods.
For now we will select name, starttime, and cpu:
Get-Process | select name, starttime, cpu
It still needs cleaned up so let's sort it:
Get-Process | select name, starttime, cpu | sort cpu
Better, but I don't really care about the processes using hardly any resources so we are going to flip the results by doing:
Get-Process | select name, starttime, cpu | sort cpu -Descending
Now with a quick glance we can see the biggest resource hogs and what time they started. Using select and sort can get you the preferred layout for your specific taste and purpose at the moment. Remember to use gm or Get-Member to find out what object properties are available to select from.
RSS Feed