Hi,
Thank you for posting your query.
Kindly follow the steps provided below to resolve your issue.
Look in the History tab for errors.
Change the task to run cmd.exe instead of powershell.exe. In the arguments field specify a bat file name, C:\PSScripts\DisableADUsers.bat
Create the .bat file to call the PS script but also redirect stdout and stderr to a log file where you can check for error messages.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\PSScripts\DisableADUsers.ps1" 1>C:\Windows\temp\DisableADUsers.log 2>&1
Go to this link for your reference and other troubleshooting procedures https://learn.microsoft.com/answers/questions/357845/powershell-script-not-working-through-task-schedul.html
-------------------------------------------------------------------------------------------------------------------------------------
If the answer is helpful kindly click "Accept as Answer" and up vote it.