0

as the title says, how do you run a script on task scheduler when RAM usage is greater than 3gb? I want to run a script that changes the power plan (already done).

My only problem is do I configure task scheduler to read RAM usage

Thanks!!

EDIT: I'm experimenting on this

while($true) {

$ram = 0

$ram = wmic OS get FreePhysicalMemory

if ($ram -ge 12000000) {
powercfg /s 9897998c-92de-4669-853f-b7cd3ecb2790
write-host("AMD balanced")
}

elseif ($ram -le 12000000){
powercfg /s a1841308-3541-4fab-bc81-f71556f20b4a
write-host("power saver")

}

write-host($ram)

}
cedie_asd
  • 45
  • 6
  • What have you tried so far? – boxdog Jun 30 '20 at 10:13
  • I already created scripts that I can run and change the powerplan. My only problem is how do the task scheduler detect the ram usage – cedie_asd Jun 30 '20 at 10:25
  • Task scheduler cannot detect the RAM usage, but it can detect and event being logged. If you find out a way to monitor your RAM, logging an event in case of high RAM your problem is solved. – Dominique Jun 30 '20 at 12:50

1 Answers1

0

I don't see an issue with running this in Task Scheduler, but you'll need to follow this StackOverflow post to configure it to run periodically.

I don't recommend running wmic because it will pop up a window, but powercfg may too. You might be able to set the power plan another way through PowerShell, but this should give you what you're looking for using Get-WMIObject.

$SysMem = Get-WmiObject Win32_OperatingSystem -Property FreePhysicalMemory

If($SysMem.FreePhysicalMemory -ge (3 * 1gb)) {
    Write-Host ("AMD Balanced")
    powercfg /s 9897998c-92de-4669-853f-b7cd3ecb2790
} else {
    Write-Host ("Power Saver")
    powercfg /s a1841308-3541-4fab-bc81-f71556f20b4a
}

This offsite article covers more power plan information.

Taylor
  • 510
  • 2
  • 5
  • 16