page contents My title page contents A Blog on Tools, Techniques and Announcements: PowerShell-Day2

Thursday, August 4, 2016

PowerShell-Day2

Pipelining
Pipelining is the term for feeding one command's output into another command. This allows the second command to act on the input it has received. To pipeline two commands (or cmdlets), simply separate them with the pipe symbol (|).
To help you understand how pipelining works, imagine that you want to create a list of processes that are running on a server and sort that list by process ID number. You can get a list of processes by using the Get-Process cmdlet, but the list will not be sorted. However, if you pipeline the cmdlet's output into the Sort-Object ID command, the list will be sorted. The string of commands used looks like this:

we were able to sort the process as per the handles used in descending order

1. 
**One Important Lesson learned is, you should never be in a hurry, hence analyse the command before you run them, the below command could get you into trouble :) 

get-service | stop-service (will stop all services)


Instead, know the parameters to be run which the command as shown below-







No comments:

Post a Comment