PoshCode Archive  Artifact [c5a1f2c9f0]

Artifact c5a1f2c9f0736b30c32c560f1520578d06f2839cb66c4140df5e8a9469a55e57:

  • File Empty-working-set.ps1 — part of check-in [24839b7655] at 2018-06-10 13:09:50 on branch trunk — Pipe filter which empties working set for any received System.Diagnostics.Process object (user: amirul size: 655)

# encoding: ascii
# api: powershell
# title: Empty working set
# description: Pipe filter which empties working set for any received System.Diagnostics.Process object
# version: 0.1
# author: amirul
# license: CC0
# x-poshcode-id: 2413
# x-archived: 2017-04-08T14:52:37
# x-published: 2011-12-18T01:46:00
#
#
# use it as follows:
# PS C:\> ps explorer | trim

add-type -Namespace Win32 -Name Psapi -MemberDefinition @"
[DllImport("psapi", SetLastError=true)]
public static extern bool EmptyWorkingSet(IntPtr hProcess);    
"@
 
filter Reset-WorkingSet {
    [Win32.Psapi]::EmptyWorkingSet($_.Handle)
}
 
sal trim Reset-WorkingSet