惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
D
Docker
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
F
Full Disclosure
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
L
LangChain Blog
H
Help Net Security
B
Blog
T
Tailwind CSS Blog
V
V2EX
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
美团技术团队
A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
I
InfoQ
Project Zero
Project Zero
I
Intezer
Google DeepMind News
Google DeepMind News
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threat Research - Cisco Blogs
Last Week in AI
Last Week in AI
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
S
Securelist
Recorded Future
Recorded Future
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 叶小钗
S
Security Affairs
Blog — PlanetScale
Blog — PlanetScale
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
The Hacker News
The Hacker News

博客园 - stefanie

SQL - 获取多机构最近相同节点 PowerShell-将CSV导入SQL Server [Powershell] 检查IIS设置 VBS 操作注册表 十六进制 无法在People Picker中选择用户 Microsoft Certification List WINDOWS 2012忘记密码之后。。。 Auto Install Workflow Manager 1.0 批量删除Kindle Personal Documents 导入Excel表格到SharePoint站点 用户中心 - 博客园 [PowerShell] Backup Folder and Files Across Network SSRS 请求并显示SharePoint人员和组字段 VS 2010 安装 .net framework2.0/3.0/3.5 How to Setup AssociatedOwnerGroup / AssociatedMemberGroup / AssociatedVisitorGroup RPC服务不可用 [转]SharePoint Versions 安装 64 位版本的 Office 2010 后,无法查看数据表视图中的列表 [MOSS]关闭弹出窗口
[Powershell] FTP Download File
stefanie · 2013-07-17 · via 博客园 - stefanie
 1 # Config
 2 $today = Get-Date -UFormat "%Y%m%d"
 3 $LogFilePath = "d:\ftpLog_$today.txt"
 4 $UserName = "ftpuser"
 5 $Password = "Password01!"
 6 
 7 
 8 function REM($Msg){
 9     $now= Get-Date
10     write-host "$now : $Msg" -foregroundcolor Yellow
11     Add-Content $LogFilePath "$now : $Msg"
12 }
13 
14 function DownloadFile($Username,$Password,$RemoteFile,$LocalFile){
15 
16     try
17     {
18         $ErrorActionPreference="Stop";
19 
20         if($RemoteFile -eq $null){ 
21             REM "RemoteFile is null"
22             return 
23         }
24         if($LocalFile -eq $null){ 
25             REM "LocalFile is null"
26             return 
27         }
28     
29         $FTPRequest = [System.Net.FtpWebRequest]::Create($RemoteFile)
30         $FTPRequest.Credentials = New-Object System.Net.NetworkCredential($Username,$Password) 
31         $FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile 
32         $FTPRequest.UseBinary = $true
33         $FTPRequest.KeepAlive = $false
34         # Send the ftp request
35         $FTPResponse = $FTPRequest.GetResponse() 
36         # Get a download stream from the server response 
37         $ResponseStream = $FTPResponse.GetResponseStream() 
38         # Create the target file on the local system and the download buffer 
39         $LocalFileFile = New-Object IO.FileStream ($LocalFile,[IO.FileMode]::Create) 
40         [byte[]]$ReadBuffer = New-Object byte[] 1024 
41         if($ResponseStream -eq $null){
42             return
43         }
44         # Loop through the download 
45         do { 
46             $ReadLength = $ResponseStream.Read($ReadBuffer,0,1024) 
47             $LocalFileFile.Write($ReadBuffer,0,$ReadLength) 
48         
49         } 
50         while ($ReadLength -ne 0)
51 
52         REM "$RemoteFile 下载成功。"
53     }
54     catch
55     {
56         REM("Exception Msg: $_")
57     }
58 
59 }
60 
61 
62 
63 DownloadFile $UserName $Password "ftp://192.168.1.103/frate.csv" "c:\downloads\frate.csv"
64 DownloadFile $UserName $Password "ftp://192.168.1.103/bcirfp.csv" "c:\downloads\bcirfp.csv" 

连接Linux机器上的ftp时候,切记文件名是区分大小写滴!