PoshCode Logo PowerShell Code Repository

Empty working set by vinicius 5 weeks ago (modification of post by amirul view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/6808"></script>download | new post

Pipe filter which empties working set for any received System.Diagnostics.Process object

  1. # use it as follows:
  2. # PS C:\> ps explorer | trim
  3.  
  4. add-type -Namespace Win32 -Name Psapi -MemberDefinition @"
  5. [DllImport("psapi", SetLastError=true)]
  6. public static extern bool EmptyWorkingSet(IntPtr hProcess);    
  7. "@
  8.  
  9. filter Reset-WorkingSet {
  10.     [Win32.Psapi]::EmptyWorkingSet($_.Handle)
  11. }
  12.  
  13. sal trim Reset-WorkingSet

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me