The following script checks for network share availability:
while($true)
{
$i++
test-path Z: |Foreach{"{0} - {1}" -f (Get-Date),$_} | Out-File "F:\script\path.log" -Append
Start-Sleep -s 5
}
OUTPUT:
True
Executing from task scheduler as same user returns false. What can be wrong?
The problem is, the Task Scheduler doesn't know the environment variablessuch as "Z:". Testing with the Fully Qualified network share name make it work.