News

 Subscribe Add to Technorati Favorites

 

 

 

 


 

 

Search My Blog:

 

 

My Stats

  • Posts - 468
  • Comments - 242
  • Trackbacks - 265

Twitter












Tag Cloud


Recent Comments


Recent Posts


Archives


Post Categories


Blogs


Miscellanous


Noteworthy Stuff


Popular Posts



ckj asked me how to "recursively upload a directory mutiple levels deep via send-ftp". Here is my answer:

For now, the send-ftp cmdlet allows you to upload one file at a time (its a beta). But you can easily use get-children's recursive flag to get a list of all the files to upload, and call send-ftp for each one. Here is a little script to do so.


param( [string] $dir = "C:\Testing\FTPTest\" )

$files = (get-childitem $dir -r)
foreach ($file in $files) {
$remfilename = $file.FullName.Replace($dir, "")
$remfilename = $remfilename.Replace("\", "/")
if ($file.Attributes -eq "Directory") {
send-ftp -server MYSERVER -user TEST -password TEST -create $remfilename
}
else {
send-ftp -server MYSERVER -user TEST -password TEST -localfile $file.FullName -remotefile $remfilename
}
Write-Host $remfilename
}

Technorati : , , ,


posted @ Thursday, December 07, 2006 11:37 AM | Filed Under [ Programming Software PowerShell ]

Comments

Gravatar # re: NetCmdlets FTP - recursive directory upload
Posted by Recurfizz on 9/17/2007 11:34 AM
How could I check if the directory already exists before creating it?
Gravatar # re: NetCmdlets FTP - recursive directory upload
Posted by Lance on 9/17/2007 3:12 PM
The command:

get-ftp -server MYSERVER -user TEST -password TEST

Will return a directory listing.

Post a comment





 

Please add 6 and 1 and type the answer here: