Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. $LogPath = "C:\test\xxx"
  2. if(-not (Test-path -Path $LogPath)){
  3. New-Item -ItemType Directory -Force -Path $LogPath
  4. }
  5. $FullFilePath = Join-Path $LogPath -ChildPath "MemoryUsage.txt"
  6. $ComputerMemory = Get-WmiObject -Class WIN32_OperatingSystem -ComputerName localhost
  7. $Memory = [math]::Round(((($ComputerMemory.TotalVisibleMemorySize - $ComputerMemory.FreePhysicalMemory)*100)/ $ComputerMemory.TotalVisibleMemorySize))
  8.  
  9. $DateStr = (Get-Date).ToString("dd.MM.yyyy HH:mm K")
  10. Add-Content -Path $FullFilePath -value "$DateStr $memory %"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement