Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script with FileTransfer as scheduled task on Win2008

445 views
Skip to first unread message

Dajo Rybski

unread,
Nov 19, 2009, 10:27:19 AM11/19/09
to
Hello,

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

Martin Zugec

unread,
Nov 20, 2009, 2:27:26 AM11/20/09
to
Hi 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...

Andrew Savinykh

unread,
Nov 20, 2009, 4:58:40 AM11/20/09
to
Tty capturing the script output when it's run in scheduled mode. This
output might give you a hint as to what is going wrong.

Dajo Rybski

unread,
Nov 20, 2009, 8:29:43 AM11/20/09
to
Hi,

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 Zugec

unread,
Nov 25, 2009, 3:22:18 PM11/25/09
to

Ok, quick idea:
on Conditions tab, specify that network should be available

Martin

"Dajo Rybski" <dajo.rybski@_REMOVETHIS_infohos.be> wrote in message

news:#rYKGWea...@TK2MSFTNGP02.phx.gbl...

Dajo Rybski

unread,
Dec 2, 2009, 3:35:10 AM12/2/09
to
Right, that did it!
Thanks a lot.

Best,
Dajo

0 new messages