Powered by GeSHi

Source code for memory.ps1

(view source code of memory.ps1 as plain text)

  1. # Memory.ps1,  Version 1.20
  2. # Display total and free amounts of physical memory in Bytes, KB and MB
  3. #
  4. # Usage:  MEMORY.PS1  [ remote_computer ]
  5. #
  6. # Written by Rob van der Woude
  7. # http://www.robvanderwoude.com
  8.  
  9. param( [string]$computer = $env:ComputerName )
  10.  
  11. $free = ( Get-WMIObject Win32_OperatingSystem -ComputerName $computer ).FreePhysicalMemory
  12. $phys = ( Get-WMIObject Win32_OperatingSystem -ComputerName $computer ).TotalVisibleMemorySize
  13.  
  14. ""
  15. "Computer: " + $computer
  16. ""
  17. "Physical memory".PadRight( 16, " " ) + "Bytes".PadLeft( 14, " " )                + "KB".PadLeft( 11, " " )            + "MB".PadLeft( 8, " " )
  18. "=" * 49
  19. "Available".PadRight( 16, " " )       + ([string]($free * 1024)).PadLeft( 14, " " ) + ([string]$free).PadLeft( 11, " " ) + ([string]([int](($free + 512) / 1024))).PadLeft( 8, " " )
  20. "Total".PadRight( 16, " " )           + ([string]($phys * 1024)).PadLeft( 14, " " ) + ([string]$phys).PadLeft( 11, " " ) + ([string]([int](($phys + 512) / 1024))).PadLeft( 8, " " )
  21. ""
  22.