Skip to content

Instantly share code, notes, and snippets.

@johnvilsack
Created May 13, 2022 19:56
Show Gist options
  • Save johnvilsack/789e76ea13f0ae2ec5c2195786f200e6 to your computer and use it in GitHub Desktop.
Save johnvilsack/789e76ea13f0ae2ec5c2195786f200e6 to your computer and use it in GitHub Desktop.
Powershell Tattoo Idea (by Request)
$TIM = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object -ExpandProperty Size
$patience = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object -ExpandProperty FreeSpace
$stress = ($TIM - $patience)
if (($stress / $TIM)*100) -gt 50) {Write-Host "Take a Break"}
# 1. $TIM is the size of C:. It never changes, so it is a constant and in all caps
# 2. $patience is the FreeSpace left. It changes and is all lowercase because it is variable
# 3. $stress is the Used Space. This is the Total Disk minus whatever is free.
# 4. $stress divided by TIM then multiplied by 100 tells you a percentage of how much total stress you are dealing with
# 5. If the percentage of stress is greater than 50, write "Take a Break" to the window.
# Try changing the -gt 50 to see the number appear or disappear depending on value compared to your disk size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment