PoshCode Logo PowerShell Code Repository

FTP ListDirectory (modification of post by view diff)
View followups from Joel Bennett | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1689"></script>download | new post

An example showing how to get a file listing via ftp. NOTE: the listing comes back in (bad) html…

  1. $cred = Get-Credential
  2.  
  3. [System.Net.FtpWebRequest]$request = [System.Net.WebRequest]::Create("ftp://joelbennett.net")
  4. $request.Method = [System.Net.WebRequestMethods+FTP]::ListDirectory #Details
  5. $request.Credentials = $cred
  6.  
  7. $response = $request.GetResponse()
  8.  
  9. $list = Receive-Stream $response.GetResponseStream()

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me