Windows Powershell (Monad)
The “real” CLI for windows. Unlike our favourite shells like bash where output of a command is text, PowerShell deals with .NET objects. This makes pipe’ing etc very convenient. For example we can do things like:-
- PS C:\Users\Chandan> ps | Where-Object {$_.Handles -gt 1000}
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
——- —— —– —– —– —— — ———–
2313 0 0 848 8 4 System
…
- PS C:\Users\Chandan> ps firefox | format-list
Id : 3432
Handles : 883
CPU : 369.8315707
Name : firefox
- PS C:\Users\Chandan> (ps firefox).get_Id()
3432
- PS C:\Users\Chandan> (ps firefox).ProductVersion
2.0.0.12
With the exposure of objects, Powershell scripting is somewhat similar to application-level scripting supported by protocols like DCOP. Another very interesting feature in PowerShell is the concept of PSDrives and Providers which enable use of generic methods for navigating filesytem, registry, environment etc.
- PS C:\Users\Chandan> psdrive
Name Provider Root CurrentLocation
—- ——– —- —————
C FileSystem C:\ Users\Chandan
Env Environment
HKCU Registry HKEY_CURRENT_USER
…
- PS C:\Users\Chandan> cd env:
- PS Env:\> ls
Name Value
—- —–
Path C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Visual Studio …
TEMP C:\Users\Chandan\AppData\Local\Temp
SESSIONNAME Console
…
Links
Video: Jeffrey Snover talks about Monad/PowerShell
Download PS
October 4th, 2011 at 6:42 pm
Saved like a favourite, I genuinely like your web site!