Hello there,
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.
The Azure PowerShell environment just needs to understand what Azure subscription to work with by default. You probably did this for your own environment, but the task scheduler is running in a different environment.
You just need to add an additional command to the beginning of your script to set the Azure subscription. Something like this:
Set-AzureSubscription -SubscriptionName
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--