Powershell and mapped drive

Anne 276 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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,431 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