I am struggling with a script that works when I run it Interactively, but dies when it is ran as a post job activity.
Post Job Activity is set to run powershell "C:\Scripts\TargetCopy.ps1 JOBNAME"
Post job runs a script that runs mostly correctly. It passes the JOBNAME parameter on and executes all of the script commands until it gets to an Invoke-Command statement that starts a script that runs on the repository.
The Invoke-Command statement is:
Invoke-Command -ComputerName IPADDRESS -Credential $mycred -FilePath $jobnamescript -ArgumentList $latestfile, $jobnamearg
When I run it through a command prompt (logged on as .\Administrator) as: powershell "C:\Scripts\TargetCopy.ps1 JOBNAME" it works fine. It is simply as a post job activity (Veeam Backup Service runs as .\Administrator) that it fails.
Any ideas? What am I missing?