I have to write a script which accesses an FTP server, and then deletes all *.zip files which are older than X days.
As clarification: The script can't run on the FTP server.
This is what I have so far:
$ftpServer = "RandomFTPServer"
$ftpUser = "Username"
$ftpPassword = Read-Host "Password" -AsSecureString
$credentials = New-ObjectSystem.Net.NetworkCredential($ftpUser, $ftpPassword)
function Get-FtpRequest($ftpPath) {
$ftpRequest = [System.Net.FtpWebRequest]::Create("$ftpServer/$ftpPath")
$ftpRequest.Credentials = $credentials
$ftpRequest.UseBinary = $true
$ftpRequest.KeepAlive = $true
$ftpRequest.UsePassive = $true
return $ftpRequest
}
Run Code Online (Sandbox Code Playgroud)
Any tips on what …