Check Space and run scheduled task

Hi all,

I need to have a ps script that check space on my disk and if is under a percentage, run a scheduled task.

Can you help me?

$disk = Get-WmiObject Win32_LogicalDisk -ComputerName MYPC-Filter "DeviceID='O:'" |Select-Object Size,FreeSpace


  • You have the raw values.

    Compute the percent free and store the results into a variable.

    Write an if () statement testing the new variable vs. your threshold. Put what you want to be run between { }