0
$today = (get-date).Date  


$dateStr = '{0:yyyyMMdd}' -f $today

New-Item C:\Desktop\test_$dateStr -ItemType directory 

ftp
open
Server Name
UserID
Password
dir
lcd C:\Desktop\test_$dateStr
prompt
binary
mget *$dateStr.txt   
mget *$dateStr.zip  
bye

我正在尝试从 FTP 服务器下载今天的 txt 文件和 zip 文件。这些文件被命名为 test_20131001 所以我设置为$dateStr但它不起作用。FTP 服务器找不到我在进入 FTP 服务器之前创建的文件夹。 lcd C:\Desktop\test_$dateStr不工作...

4

1 回答 1

0

lcd and mget are interpreted by FTP.exe, not PowerShell. FTP.exe isn't going to understand $dateStr. Take a look at this FTPClient module as one way to automate FTP download in PowerShell.

于 2013-10-09T21:05:09.360 回答