Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell等待并释放_Powershell_Process_Ftp - Fatal编程技术网

Powershell等待并释放

Powershell等待并释放,powershell,process,ftp,Powershell,Process,Ftp,我的脚本有些完整,但我想在其中添加一些进程处理: #Call Bluezone to do file transfer & "C:\Program Files (x86)\BlueZone FTP\6.1\Bzftpf.exe" /F"ccaihfs.zft" #Variable Declarations $source = "\\fhnsrv01\home\aborgetti\Documentation\Stage\" $dest = "\\fhnsrv01\home\aborgett

我的脚本有些完整,但我想在其中添加一些进程处理:

#Call Bluezone to do file transfer
& "C:\Program Files (x86)\BlueZone FTP\6.1\Bzftpf.exe" /F"ccaihfs.zft"
#Variable Declarations
$source = "\\fhnsrv01\home\aborgetti\Documentation\Stage\"
$dest = "\\fhnsrv01\home\aborgetti\Documentation\Stage\orig"
$archive = "\\fhnsrv01\home\aborgetti\Documentation\Stage\archive"

#First copy the original file to the orig folder before any manipulation takes place
Copy-item $source\*.EDIPROD $dest
# Now we must rename the items that are in the folder
Switch(GCI \\fhnsrv01\home\aborgetti\Documentation\Stage\*.EDIPROD){
    {(GC $_|Select -first 1).substring(176) -match "^834"}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName {"834Dailyin$($Matches[1]).txt"};Continue}
    {(GC $_|Select -first 1).substring(176) -match "^820"}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName {"820Dailyin$($Matches[1]).txt"};Continue}
    {(GC $_|Select -first 1) -match "NO INPUT"}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName {"NOINPUTin$($Matches[1]).txt"};Continue}
    {(GC $_|Select -first 1) -match ""}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName Default {"Could not find 834 or 820 qualifier in file $_"};Continue}
}
#move files older than 1 month to archive
$date = (get-date).AddDays(-31)
GCI \\fhnsrv01\home\aborgetti\Documentation\Stage\*.txt| Where{$_.CreationTime -lt (get-date).adddays(-31)}| move-item -destination $archive
这样做很好,唯一的问题是这条线:

& "C:\Program Files (x86)\BlueZone FTP\6.1\Bzftpf.exe" /F"ccaihfs.zft"
它正在调用一个FTP程序。问题是这个过程需要一段时间。结果将与脚本的其余部分一起处理。但是powershell速度如此之快,它只需要在文件传输完成之前完成它必须完成的工作

我在FTP程序中设置了一些自动配置选项,以便在文件传输完成后自动关闭。这将释放该程序的PID/mem

我知道PS可以处理这种情况。只是不知道怎么做


我想我要做的是将PS搁置,直到处理完成,然后当它释放PID时,完成脚本。

听起来EXE是一个GUI应用程序,对吗?如果是,请尝试此操作使PowerShell等待GUI应用程序退出:

& "C:\Program Files (x86)\BlueZone FTP\6.1\Bzftpf.exe" /F"ccaihfs.zft" | Out-Null