PoshCode Archive  Artifact [60425a5cf5]

Artifact 60425a5cf53f33772db947653a84b9c1b562af2516dea1669caa90f083478b15:

  • File FTP-ListDirectory.ps1 — part of check-in [7aa44e25a4] at 2018-06-10 13:00:07 on branch trunk — An example showing how to get a file listing via ftp. NOTE: the listing comes back in (bad) html… (user: Joel Bennett size: 662)

# encoding: ascii
# api: powershell
# title: FTP ListDirectory
# description: An example showing how to get a file listing via ftp.  NOTE: the listing comes back in (bad) html…
# version: 0.1
# author: Joel Bennett
# license: CC0
# x-poshcode-id: 1689
# x-archived: 2017-01-24T14:26:36
# x-published: 2011-03-11T07:26:00
#
#
$cred = Get-Credential

[System.Net.FtpWebRequest]$request = [System.Net.WebRequest]::Create("ftp://joelbennett.net")
$request.Method = [System.Net.WebRequestMethods+FTP]::ListDirectory #Details
$request.Credentials = $cred

$response = $request.GetResponse()

$list = Receive-Stream $response.GetResponseStream()