Get-WinSCPChildItem


Synopsis

Shows the contents of a remote directory.


Syntax

Get-WinSCPChildItem [-WinSCPSession] <Session> [[-Path] <String[]>] [[-Filter] <String>] [-Recurse] [<CommonParameters>]

Description

Displays the contents within a remote directory, including other directories and files.


Parameters

WinSCPSession <WinSCP.Session>

A valid open WinSCP Session, returned from New-WinSCPSession.

  • Required: True
  • Position: 0
  • Default Value:
  • Accept Pipeline Input: True (ByValue)
  • Accept Wildcard Charcters: False

Path <String[]>

Specifies a path to one or more locations. Wildcards are permitted. The default location is the home directory of the user making the connection.

  • Required: False
  • Position: 1
  • Default Value:
  • Accept Pipeline Input: True (ByPropertyName)
  • Accept Wildcard Characters: False

Filter <String>

Filter to be applied to returned objects.

  • Required: False
  • Position: 2
  • Default Value:
  • Accept Pipeline Input: False
  • Accept Wildcard Characters: False

Recurse <SwitchParameter>

Return items from all sub directories.

  • Required: False
  • Position: 3
  • Default Value:
  • Accept Pipeline Input: False
  • Accept Wildcard Characters: False

CommonParameters <CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable.


Inputs

WinSCP.Session

  • Represents a session and provides methods for manipulating remote files over SFTP, SCP or FTP session.

System.String

  • Represents text as a series of Unicode characters.

Outputs

System.Array

  • Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.

Notes

If the WinSCPSession is piped into this command, the connection will be closed and the object will be disposed upon completion of the command


Example 1

PS C:\> New-WinSCPSession -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $env:USERNAME, (New-Object -TypeName System.Security.SecureString)) -HostName $env:COMPUTERNAME -Protocol Ftp | Get-WinSCPChildItem -Path '/rDir/'

   Directory: /rDir

FileType             LastWriteTime     Length Name
--------             -------------     ------ ----
D             1/1/2015 12:00:00 AM          0 rSubDir
-             1/1/2015 12:00:00 AM       

Example 2

PS C:\> $credential = Get-Credential
PS C:\> $session = New-WinSCPSession -Credential $credential -Hostname 'myftphost.org' -SshHostKeyFingerprint 'ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx'
PS C:\> Get-WinSCPChildItem -WinSCPSession $session -Path '/rDir/' -Recurse

   Directory: /rDir

FileType             LastWriteTime     Length Name
--------             -------------     ------ ----
D             1/1/2015 12:00:00 AM          0 rSubDir
-             1/1/2015 12:00:00 AM          0 rTextFile.txt


   Directory: /rDir/rSubDir

FileType             LastWriteTime     Length Name
--------             -------------     ------ ----
-             1/1/2015 12:00:00 AM          0 rSubDirTextFile.txt

Fork me on GitHub