简体   繁体   English

powershell 位传输 object 引用未设置为 object 的实例

[英]powershell bitstransfer object reference not set to an instance of an object

i have a program written in C# that uses powershell bitstransfer to upload and download a file from a machine.我有一个用 C# 编写的程序,它使用 powershell 位传输从机器上传和下载文件。 its been working fine until today when the upload and download stopped working giving this error.它一直工作正常,直到今天上传和下载停止工作并给出此错误。 It seems like the error is local to my machine because other machines work properly with bitstransfer and restarting the machine didn't fix the problem.似乎该错误是我机器的本地错误,因为其他机器可以正常使用 bitstransfer 并且重新启动机器并没有解决问题。 Could someone help me out?有人可以帮我吗? Thanks谢谢

PS Start-BitsTransfer -Source \\ip\data\filename.xml -Destination G:\\PLAYGROUND\\dir\\\
Start-BitsTransfer : Object reference not set to an instance of an object.
At line:1 char:19
+ Start-BitsTransfer <<<<  -Source \\ip\data\filename.xml -Destination G:\\PLAYGROUND\\dir\\\
    + CategoryInfo          : NotSpecified: (:) [Start-BitsTransfer], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.BackgroundIntelligentTransfer.Management.NewBits
   TransferCommand


    PS Start-BitsTransfer -Source G:\\PLAYGROUND\\dir\\file.txt -Destination \\\\ip\\data\\\
Start-BitsTransfer : Object reference not set to an instance of an object.
At line:1 char:19
+ Start-BitsTransfer <<<<  -Source G:\\PLAYGROUND\\dir\\file.txt -Destination \\\\ip\\data\\\
    + CategoryInfo          : NotSpecified: (:) [Start-BitsTransfer], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.BackgroundIntelligentTransfer.Management.NewBits
   TransferCommand

我改用复制命令修复了它。

I think this happens when you have a high number of asynchronous jobs.我认为当您有大量异步作业时会发生这种情况。 All jobs in my case where either in failed or transferred state and after running Get-BitsTransfer | Remove-BitsTransfer在我的情况下,处于失败或转移状态以及运行Get-BitsTransfer | Remove-BitsTransfer后的所有作业Get-BitsTransfer | Remove-BitsTransfer Get-BitsTransfer | Remove-BitsTransfer I was able to start bits transfer. Get-BitsTransfer | Remove-BitsTransfer我能够开始位传输。

I ran into this as well.我也遇到了这个。 If I added 60 transfers in quick succession I'd start getting errors.如果我快速连续添加 60 次传输,我会开始出错。 Here's how I handled it:以下是我的处理方式:

try {
    $ErrorActionPreference = 'Stop'
    Start-BitsTransfer $downloadUrl -Description $assetName -Destination $assetDestinationFolder -Asynchronous | Out-Null
}
catch {
    #If too many transfers are queued at once the process begins to fail. This takes care of that problem.

    while ($true) {
        Write-Host "Queue full. Waiting for other downloads to finish. $((Get-BitsTransfer).Count) downloads in progress." -ForegroundColor Yellow

        Start-Sleep -Seconds 1

        Get-BitsTransfer | Format-Table -Property Description, JobState

        Get-BitsTransfer | Where-Object { $_.JobState -eq "Transferred" } | Complete-BitsTransfer

        Get-BitsTransfer | Where-Object { $_.JobState -like "*Error" -or $_.JobState -eq "Cancelled" } | ForEach-Object { $_ | Remove-BitsTransfer }

        try {
            Start-BitsTransfer $downloadUrl -Description $assetName -Destination $assetDestinationFolder -Asynchronous | Out-Null
            break;
        }
        catch {
            continue;
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Powershell对象引用未设置为对象的实例 - Powershell Object reference not set to an instance of an object Azure PowerShell-对象引用未设置为对象的实例 - Azure PowerShell - Object reference not set to an instance of an object Powershell Core中的“对象引用未设置为对象的实例” - "Object reference not set to an instance of an object" in Powershell Core Powershell Set-Item 返回未设置为实例对象的对象引用 - Powershell Set-Item returns Object reference not set to an object of an instance PowerShell新项目-对象引用未设置为对象的实例 - PowerShell New-item - Object reference not set to an instance of an object PowerShell 给出错误“对象引用未设置到实例对象” - PowerShell giving an error "Object reference not set to an instance object" Function 从 Powershell 5 移植到 Powershell 7 失败,并显示“对象引用未设置为对象的实例” - Function ported from Powershell 5 to Powershell 7 fails with “object reference not set to an instance of an object” PowerShell导入的dll无法正常工作:使用“ 0”参数调用“ ReadLookupTables”的异常:“对象引用未设置为对象的实例 - PowerShell imported dll not working: Exception calling “ReadLookupTables” with “0” argument(s): "Object reference not set to an instance of an object AzCosmosDBSqlContainer:“对象引用未设置为 object 的实例。” - AzCosmosDBSqlContainer : “Object reference not set to an instance of an object.” Powershell位传输 - Powershell Bitstransfer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM