PowerShell Script Not Running from Task Scheduler

Niranjan Thyagaraja 0 Reputation points
2025-06-11T21:47:19.5366667+00:00

Hi All,

I've created a short powershell script to check the following and send an email notification if any of these conditions are met:

  1. system rebooted in the last 'x' mins.
  2. zohoworkdrive background process is not running.
  3. Z: drive is not mapped or not accessible.

Here is the script with its extension changed to .txt for attachment compatibility: ZohoWorkDrive-Checks-NT-ps1.txt

This script runs perfectly fine from the command prompt, however, when I try to run it through the windows task scheduler, it seems to do something for exactly 2 minutes (which normally takes fraction of second from cmd), but doesn't end up sending any email notification.

Based on a similar issue (in title) brought up by another user in this forum and related answers, I even tried to use the following batch script in the task scheduler that calls PS script. No luck with this either.. ZohoWorkDrive-Checks-NT-bat.txt

I am using the admin login throughout, so permissions may not be the issue as well..

Any help is very much appreciated!

-NT

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2025-06-12T00:00:41.45+00:00

    Add statements in your script to generate a transcript file. Check that log file for errors.

    See https://learn.microsoft.com/en-us/answers/questions/2281006/powershell-script

    Note that if you have set the task to "run whether the user is logged on or not" then the task scheduler will do a user impersonation and not a full desktop logon, so your "Z" drive may not be visible to the script.

    0 comments No comments

  2. Olaf Helper 47,436 Reputation points
    2025-06-13T05:39:51.8133333+00:00

    Z: drive is not mapped or not accessible.

    A NAS share is mapped to a user profile, not in general/for all.

    If the job don't run in an interactive user context, it can't work, of course. You have to setup an (your) account for the job.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.