I am running powershell scripts from the Windows 2016 task scheduler that execute a program using either UNC paths or a drive mapped in the script.
Both variants run fine in powershell but do not work when run from the task.
I know the scripts are executing because of the messages in the mapped drive variant.
I am running powershell on the server using the same user account used in the task.
The application requires DLLs that are located in the ..\runtime folder shown in the scripts.
The UNC script is:
This just fails silently.
The mapped drive script is:
If (!(Test-Path X:))
New-PSDrive -Name X -PSProvider FileSystem –Root "\\myserver\apps"
This version generates warnings in the powershell event log of "Provider Health: Could not find the drive 'X:\'. The drive might not be ready or might not be mapped." for both lines where the X: drive location is referenced