title: Can PowerShell use FTP to retrieve remote folder and subfolder directory data in a single transmission?
body: <p>I have a PowerShell script that checks existing timestamp data for files at a remote location to compare with files locally.  </p>
  
  <p>The local information is retrieved with this snippet:</p>
  
  <pre><code>$SrcEntries = Get-ChildItem $FolderLocation -Recurse
  </code></pre>
  
  <p>I can then get the specific information on folders and files with the following snippet:</p>
  
  <pre><code>$Srcfolders = $SrcEntries | Where-Object{$_.PSIsContainer}
  $SrcFiles = $SrcEntries | Where-Object{!$_.PSIsContainer}
  </code></pre>
  
  <p>The remote information is currently retrieved with this snippet which is executed individually for each file:</p>
  
  <pre><code>$Credentials = New-Object System.Net.NetworkCredential($FTPUser,$FTPPassword)
  $FTPrequest = [System.Net.FtpWebRequest]::Create($RemoteFilePath)
  $FTPrequest.Method = [System.Net.WebRequestMethods+FTP]::GetDateTimestamp
  $FTPrequest.Credentials = $Credentials
  $response = $FTPrequest.GetResponse().StatusDescription
  </code></pre>
  
  <p>The <code>$response</code> is then parsed to retrieve the timestamp of the remote file.</p>
  
  <p>It would seem better to retrieve the remote data the same way local data is retrieved, i.e. in a single operation as with the first snippet above to avoid the multiple round trips to the remote server.</p>
  
  <p>Is it possible to get folder and file directory data recursively in a single quick FTP operation using PowerShell?  How would I do that?</p>