2 ms·
PowerShell cmdlets return (active) objects in the same process space as the hosting process (usually the shell). As such they can expose expensive-to-compute pr
by useerup 11y ago
PowerShell cmdlets return (active) objects in the same process space as the hosting process (usually the shell). As such they can expose expensive-to-compute properties as late-evaluated properties that are only evaluated if and when they are invoked later.
Take for instance Get-Process:
$p = ps powershell
(ps is an alias for Get-Process). Now $p is the process information onject about the PowerShell process itself.
Type
$p
And PowerShell will respond with
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
359 24 57096 61972 611 2,20 9608 powershell
If you request the content of $p at some later point in time, you will notice how the CPU has increased, for instance. The point is that a lot of the properties are computed when read, and hence do not incur overhead in the pipeline.