【问题标题】:How to use BITS in Powershell to upload / download files?Powershell中如何使用BITS上传/下载文件?
【发布时间】:2010-12-08 17:34:46
【问题描述】:

我在 Google 中找到了一些与此相关的页面,但它们要么不完整,要么已过时。某处有明确的指南吗?谢谢

【问题讨论】:

    标签: powershell-2.0 microsoft-bits bits-service


    【解决方案1】:

    PowerShell 中总是有帮助:

    PS> import-module bitstransfer
    PS> gcm *bits* | ? {$_.Commandtype -eq "cmdlet"}
    
    CommandType Name                  Definition
    ----------- ----                  ----------
    Cmdlet      Add-BitsFile          Add-BitsFile [-BitsJob] <BitsJob[]> [-S...
    Cmdlet      Complete-BitsTransfer Complete-BitsTransfer [-BitsJob] <BitsJ...
    Cmdlet      Get-BitsTransfer      Get-BitsTransfer [[-Name] <String[]>] [...
    Cmdlet      Remove-BitsTransfer   Remove-BitsTransfer [-BitsJob] <BitsJob...
    Cmdlet      Resume-BitsTransfer   Resume-BitsTransfer [-BitsJob] <BitsJob...
    Cmdlet      Set-BitsTransfer      Set-BitsTransfer [-BitsJob] <BitsJob[]>...
    Cmdlet      Start-BitsTransfer    Start-BitsTransfer [-Source] <String[]>...
    Cmdlet      Suspend-BitsTransfer  Suspend-BitsTransfer [-BitsJob] <BitsJo...
    

    告诉你可用的命令。

    然后您可以在这些问题上致电Get-Help。从我所见,帮助条目非常有用。并且不要忘记Get-Help ... -Examples 以获得详细和带注释的使用示例。并且这些 cmdlet 的命名已经一目了然。

    【讨论】:

    • 注意补充:您可以使用Get-Module -ListAvailable 找出您可以导入的模块。
    • 更好的方法是查看模块中的命令行开关。在这种情况下, gcm -module bitstransfer 是查看组的更好方法。
    • 注意:PowerShell Core 似乎(还)不支持此功能:import-module : Module 'C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\bitstransfer\bitstransfer.psd1' does not support current PowerShell edition 'Core'.(我知道该问题已标记为 PowerShell 2.0 - 只是为寻找核心的任何人提供的提示解决方案)。
    【解决方案2】:

    如果您需要围绕这些 BITS Cmdlet 的某种 GUI,您可以尝试 BITS 文件传输 Powerpack。

    http://powergui.org/entry.jspa?externalID=2583&categoryID=21

    【讨论】:

    • 它不是 PowerShell,但 BITS 团队制作了一个示例 C# 应用程序,让您可以查看和控制 BITS 传输的制作方面。查看应用程序的GitHub(有一个安装程序示例 EXE)。如果您是 C# 程序员,请查看docs.microsoft.com的新 ​​C# 文档
    【解决方案3】:

    另一种选择是查看用于文件传输的 JAMS 作业调度程序 PowerShell cmdlet。它使管理跨不同平台的传输变得简单。

    【讨论】:

    • 您能否添加更多细节以使这个问题成为更好的答案?
    猜你喜欢
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    相关资源
    最近更新 更多