很抱歉一直询问 Powershell,我的 script-foo 不是它需要的。
我正在编写一个 BitsTransfer .PS1 来自动每周下载一个 ASCII 文件。
它似乎永远不会完成并达到“已转移”状态,并且似乎停滞在“正在转移”状态。我可以在我的 -Destination 文件夹中看到一个 TMP 文件,其中包含我的 ASCII 数据。
当我手动下载目标文件并将其与 TMP 文件进行比较时,它们的大小相同,并且似乎具有相同的第一条和最后一条记录。我假设下载完成。
如果我手动运行 Get-BitsTransfer | Complete-BitsTransfer,TMP 文件消失但仍然没有-Destination 文件。
我的剧本并不复杂...
$date= Get-Date -format yyMMdd
$ntispasswd = ConvertTo-SecureString "*******" -AsPlainText -Force
$ntiscreds = New-Object System.Management.Automation.PSCredential ("*******", $ntispasswd)
$jobdescriptor = "DMFWA" + $date
$dmfpath = "C:\DMF"
# -Source https://dmf.ntis.gov/dmldata/weekly/WA$date `
Import-Module BitsTransfer
Start-BitsTransfer `
-DisplayName $jobdescriptor `
-Priority High `
-ProxyUsage Override `
-ProxyList mckwebfilt1:3128 `
-RetryInterval 60 `
-TransferType Download `
-Source https://dmf.ntis.gov/dmldata/weekly/WA130322 `
-Destination $dmfpath\TestWA$date.txt `
-Authentication Basic `
-Credential $ntiscreds `
-Asynchronous
$job = Get-BitsTransfer $displayname
While($Job.Jobstate -ne 'Transferred'){
$job
Start-Sleep -s 1
}
Complete-BitsTransfer $job
谁能帮我理解我做错了什么?