Try creating a PSDrive at the start of your script. Make sure that the account running the script(through task scheduler) has the required rights on the share.
New-PSDrive –Name "K" –PSProvider FileSystem –Root "\\server\data"
#.... something something, creating $output variable etc.
Get-ChildItem -Recurse $source -Filter *.prt | Where{$_.LastWriteTime -gt (Get-Date).AddDays(-6)} | sort LastWriteTime -descending | select name,LastWriteTime,Directory | convertto-html -head $a -body "<H2>FILES LIST FOR PAST 7 DAYS</H2>" | out-file $output\result.htm