Skip to content

Get WinSCPChildItem

Thomas Malkewitz edited this page Sep 5, 2015 · 19 revisions

##Syntax

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

##Comment Based Help

  • SYNOPSIS

    Shows the contents of a remote directory.

  • DESCRIPTION

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

  • INPUTS

    WinSCP.Session.

    System.String.

  • OUTPUTS

    System.Array.

  • PARAMETER WinSCPSession

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

  • PARAMETER Path

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

  • PARAMETER Filter

    Filter to be applied to returned objects.

  • PARAMETER Recurse

    Return items from all subdirectories.

  • EXAMPLE

    PS C:\> New-WinSCPSession -Credential (New-Object -TypeName System.Managemnet.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          0 rTextFile.txt 
  • EXAMPLE
    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