PowerShell - 使用BITS协议作为计划任务传输文件 - 注销时不工作 [英] PowerShell - Transfer Files Using BITS protocol as a scheduled task - Not Working When logged off

查看:190
本文介绍了PowerShell - 使用BITS协议作为计划任务传输文件 - 注销时不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我编写了一个PowerShell脚本,该脚本使用BITS传输协议将大型文件从源计算机传输到目标计算机。当我运行PowerShell脚本手动登录到目标远程计算机时(文件需要复制
),文件将被复制而没有任何问题。 


但是当我创建了一个在特定时间每天运行PowerShell脚本的计划任务时。它会抛出以下错误 


"由于用户尚未登录网络,因此未执行请求的操作。指定的服务不存在。 (HRESULT异常:0x800704DD) "


只有登录我的目标机器时脚本才能运行正在复制文件的位置。如果我在该计划任务时间从该计算机注销,那么我将收到
错误。 请建议即使我从该计算机注销也需要做什么才能使计划任务运行。 


谢谢和问候


AKSrinivas(Kamal)





Kamal

解决方案

BITS要求用户登录才能运行。这就是为什么当你手动运行它时它适用于你。如果您注销,BITS将无法使用常规用户帐户。我通过在Scheduled
任务上使用LocalSystem或NetworkService帐户来实现此功能。这些系统/服务用户总是登录,因此即使没有人登录也会运行任务。请参阅下面的源文档。


https://msdn.microsoft.com/en-us /library/windows/desktop/aa363152(v=vs.85).aspx


Hello,

I have written a PowerShell script which uses the BITS transfer protocol in order to transfer large files from Source machine to destination machine. When i run the PowerShell script manually logging into my destination remote machine(Where the files need to be copied) then the files are getting copied without any issues. 

But When I have created a scheduled task that runs the PowerShell script daily at a particular time.it is throwing the following error 

"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)"

The script is getting worked only when i log-in to my destination machine where the file is being copied. If at all i log off from that machine at that scheduled task time then i am getting the error .  Please suggest on what needs to be done in order to make the scheduled task run even if i log off from that machine. 

Thanks and Regards

A.K.Srinivas(Kamal)


Kamal

解决方案

BITS requires a user to be logged in to run. So that's why it works for you when you run it manually. If you log off, BITS will not work with a regular user account. I have gotten this to work by using a LocalSystem or NetworkService account on the Scheduled Task. These system/service users are always logged on so the task will run even when nobody is logged in. See source documentation below.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363152(v=vs.85).aspx


这篇关于PowerShell - 使用BITS协议作为计划任务传输文件 - 注销时不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆