Getting the timestamp of a file from a SFTP server using ls Getting the timestamp of a file from a SFTP server using ls powershell powershell

Getting the timestamp of a file from a SFTP server using ls


Ways to do that:I. You can parse date in string and try to find 4 numbers in a row. Also add checking of containig "19","20" or $targetYear going firsts.

II. Also you may use "ls -l --full-time" command showing year.

III. And at last in my practice working with files in remote Linux servers I used:

  1. mounting remote directory as disk "New-PSDrive -name $diskLiteral -psprovider FileSystem -Root $outsightFolder -Credential $cred"
  2. geting sorted list of files in directory "Get-ChildItem ($diskLiteral + $subfolder) -Force | Where-Object $_.CreationTime -ge $targetDate"
  3. unmounting directory "Remove-PSDrive -Name $diskLiteral -Force -PSProvider FileSystem".

    On second step you can add any sorting as you want, select any information about files and Format-Table (if it nessesary table form of data representation).