# 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
