I'm struggling to get a PowerShell script that uses the FileTransfer
module to function correctly when run as a scheduled task on Windows
Server 2008.
Consider this piece of test code:
---------
import-module FileTransfer
$job = New-FileTransfer -ServerFileName
http://www.somesite.com/somefile.htm -ClientFileName
c:\temp\somedownloadedfile.htm -Asynchronous -Suspended
Clear-Filetransfer $job
---------
This should create a suspended bits-job and remove it immediately.
When this script is invoked on the shell it works fine. Check with
"bitsadmin /list /allusers" in cmd and it lists 0 jobs.
Schedule this script with Task Scheduler in Windows 2008 and it fails to
clear the job. Bitsadmin still lists the job.
All clear operations like "clear-filetransfer" and even calling
"bitsadmin /reset /allusers" from PowerShell fail when the script is run
as a scheduled task.
The user account of the scheduled task is local admin and it's the same
account i use to try it interactively. And, when run as a scheduled task
on Windows 2003, it works fine.
Any ideas?
Dajo
first, can you give us some information about error with which it fails??
Anyway, one idea - try to set that scheduled task to "Run with highest
privileges", errors can be related to UAC.
Martin
"Dajo Rybski" <dajo.rybski@_REMOVETHIS_infohos.be> wrote in message
news:uaX#JzSaKH...@TK2MSFTNGP06.phx.gbl...
The error is:
The operation being requested was not performed because the
user has not logged on to the network. The specified service does not
exist. (Exception from HRESULT: 0x800704DD)
I believe this has to do with the way BITS works, the BITS job owner
needs to be logged on (interactively or a RDP session) to let the job
continue. For some reason the account of the scheduled task is not
considered as logged on even if it is.
The high privilege checkbox nor UAC on or off have any influence...
Cheers
Dajo
Martin
"Dajo Rybski" <dajo.rybski@_REMOVETHIS_infohos.be> wrote in message
news:#rYKGWea...@TK2MSFTNGP02.phx.gbl...
Best,
Dajo