Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Woods13

Trying to Scan my SFTP Server for a file uploaded in the last 60 mins

Hello,
Im trying to scan my SFTP server for any file thats been uploaded in the last 60 mins.

So Far I have:
# Set credentials to a PSCredential Object.
$credential = Get-Credential
 
# Create a WinSCP Session.
$session = New-WinSCPSession -Hostname xxxxxxx -Credential $credential -SshHostKeyFingerprint ""ssh-ed25519 255 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""
 
# Using the WinSCPSession, show files in the directory.
Get-WinSCPChildItem -WinSCPSession $session -Path /sftperic
 
# Remove the WinSCPSession after completion.
Remove-WinSCPSession -WinSCPSession $session

I keep getting an error
New-WinSCPSession : A parameter cannot be found that matches parameter name 'Hostname'.

At line:5 char:30
+ $session = New-WinSCPSession -Hostname xxxxxxx -Credential $cre ...
+                              ~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-WinSCPSession], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,New-WinSCPSession
 
Get-WinSCPChildItem : Missing an argument for parameter 'Path'. Specify a parameter of type 'System.String[]' and try again.
At line:8 char:45
+ Get-WinSCPChildItem -WinSCPSession $session -Path
+                                             ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-WinSCPChildItem], ParameterBindingException
    + FullyQualifiedErrorId : MissingArgument,Get-WinSCPChildItem

Im fairly new with scripting and powershell in general so any suggestions anyone has would help greatly.