Powershell script will not run as a Scheduled Task

I have a script that is called from a VBS script that will not run if executed as a scheduled task

When I run it from the scheduled task I get the following error
Get-Content : Cannot find drive. A drive with the name 'l' does not exist.
At C:\powershell\sendlog.ps1:11 char:9
+ $Body = Get-Content $BodyPath | Out-String
+         ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (l:String) [Get-Content], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetContentCommand

The code that it is executing is

$BodyPath = "l:\logs\events.html"
$Body = Get-Content $BodyPath | Out-String
$attArray=@(Get-ChildItem "l:\logs\*.png" | Where {-NOT $_.PSIsContainer}) | foreach {$_.fullname}

The drive does exist and can be accessed, no problem.
If I execute the same VBS script from a CMD prompt or from within a Powershell Command Line Window I get no errors and everything runs fine

Does anyone have any suggestions

Thanks for the help
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is this drive letter local or a mapping to a network share?

Your scheduled task is most likely running in an execution context where the drive letter is not defined. Setting the login for the scheduled task may help.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
c7c4c7Author Commented:
It's a mapped drive
What does Setting the login for the scheduled task mean
c7c4c7Author Commented:
Never even paid any attention to that field, thanks for the suggestion
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.