Powershell and mapped drive

Anne 281 Reputation points
2023-05-09T22:31:36.33+00:00

I have a .bat script that is called by a windows task scheduler job.

It is run by an account of sys$pAdmin in windows task scheduler,

in the .bat file there are some database refresh tasks, then later in the script there is a call to a powershellscript like this:


..........

start powershell.exe -ExecutionPolicy Bypass -command "B:\Backup_Scripts\SetImageServer.ps1 F:\oradata\psproddb\data_pump_dir\rman_dup_%LOG_DAY%.log | Out-File F:\oradata\psproddb\data_pump_dir\rman_dup_%LOG_DAY%_2.log"

There is nothing recorded in the log for it.

I know B drive is a mappped drive, And I cannot find a mapped drive of B:, and nothing mentioned in the script about mapping B drive,

Is there a way I can see if it has a mappped drive setup?

THanks,

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

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2023-05-10T02:17:44.4133333+00:00

    A job started by the task scheduler doesn't have access to mapped drives outside the scope of the job. Try mapping the drive as part of the job. E.g., NET USE B: \server\directory -- or, better, don't depend on mapped drives; use the UNC name instead.

    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.