Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. VERBOSE: Performing the operation "Remove item from ftp location" on target "ftp:/domain.com/.cagefs".
  2. VERBOSE: Use original path: domain.com/.cagefs
  3. VERBOSE: Remove additonal slash: domain.com/.cagefs
  4. VERBOSE: Path is directory
  5. VERBOSE: Use WebRequestMethods: LIST
  6. VERBOSE: Use original path: domain.com/.cagefs.
  7. VERBOSE: Remove additonal slash: domain.com/.cagefs.
  8. VERBOSE: Path is directory
  9. VERBOSE: Use WebRequestMethods: LIST
  10. VERBOSE: Use original path: domain.com/.cagefs/..
  11. VERBOSE: Remove additonal slash: domain.com/.cagefs/..
  12.  
  13. `Import-Module PSFTP`
  14. `$FTPServer = 'domain.com'`
  15. `$FTPUsername = 'username'`
  16. `$FTPPassword = 'password'`
  17. `$FTPSecurePassword = ConvertTo-SecureString -String $FTPPassword -asPlainText -Force`
  18. `$FTPCredential = New-Object System.Management.Automation.PSCredential($FTPUsername,$FTPSecurePassword)`
  19.  
  20. `Set-FTPConnection -Credentials $FTPCredential -Server $FTPServer -Session MySession -UsePassive`
  21.  
  22. `$Session = Get-FTPConnection -Session MySession`
  23.  
  24. `$output = Get-FTPChildItem -Session $Session -Path '/' | Select ModifiedDate, Name | Where-Object {($_.ModifiedDate -lt (Get-Date).AddDays(-7))}|select name `
  25.  
  26. `echo $output`
  27.  
  28. foreach ( $file in $output ) {
  29. Remove-FTPItem $file.name -Recurse -Session $Session -Verbose
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement