I need a script that will delete all files from a ftp directory, and then upload a folder on my local machine to that same ftp location. Any ideas?? Thanks in advance
Asked
Active
Viewed 4,139 times
0
-
Do you have a FTP client to use already or are you wanting to do it in pure powershell? – GrayWizardx Dec 15 '09 at 18:50
3 Answers
1
$ftprequest = [System.Net.FtpWebRequest]::Create($Sourceuri)
$ftprequest.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::DeleteFile
$ftprequest.GetResponse()

Unconn
- 578
- 4
- 5
0
Powershell doesn't have anything built-in for this, but you could use FtpWebRequest and other related .NET classes to access FTP sites.
If you want a cmdlet, then you could check out NetCmdlets. It appears to be free for personal use.

bobbymcr
- 23,769
- 3
- 56
- 67
-
any exmples of how to use ftpwebrequest, sorry this is my first day of using powershell – Rod Johnson Dec 15 '09 at 19:51
0
This might be a helpful place to start. You are going to need to implement each FTP function you want to use (GetDirectoryList, Upload, Delete) either using native .NET code or using your .NET DLL or client.

Community
- 1
- 1

GrayWizardx
- 19,561
- 2
- 30
- 43