Linux! Shell ! these are probably the most uttered words in any tech discussion. I admit that i like linux a bit and a frequent visitor of the desktop screen of ubuntu in my dual boot setting. Its true that you can pretty much “operate” linux from its shell and Microsoft’s equivalent to it (or atleast thats what it seem like) is the Powershell utility. I wouldn’t consider it as omnipotent as Linux’s shell but it managed to kindle my curiosity
This was my first useful powershell command:
gci -r | where {$_.name -eq "target" } | rm -recurse
looks similar?? This script searches from current working directory recursively and removes all the “target” directory. In case you haven’t guessed it the above command is ps substitute for `mvn clean`. Unlike linux shell commands the output of each powershell command is not restricted to a text stream but rather a object stream that can be processed by subsequently piped commands.
Some commands you might find useful,
1. ‘gm’ that lets you reflect on the properties of the passed powershell object
2. ‘Sort’ – sorts the powershell objects based on property. For example if you want to view the processes in decreasing order of the PagedMemorySize, you need to key in,
ps | sort –des PagedMemorySize
3. saps / Start-Process – starts a new process.
Note: Each elaborate powershell command has a nifty alias that is easier to type . Command that lists the alias – command pairs,
Get-Alias | select Name,ResolvedCommandName | more