Powershell、ftp、get-childitem
-
04-10-2019 - |
题
对 powershell 来说没什么新意。我正在尝试找到一个类似于 get-childitem 的命令,该命令将在 ftp 站点上运行。
这是一些伪代码:
$target = "c:\file.txt"
$username = "username"
$password = "password"
$ftp = "ftp://$username:$password@myftpsite"
$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)
#below is the code that does not work, get-childitem needs a local path
$name = get-childitem -path $ftp
get-childitem 仅适用于本地路径。有谁知道我如何在 ftp 站点上以这种方式访问文件名?
谢谢
解决方案
如果您希望 Get-ChildItem 在通过 FTP 访问的远程文件系统上工作,您需要的是 FTP 的 PowerShell 提供程序。这 论坛帖子 提到 Nick Howell 在 FTP 提供商方面所做的工作。除此之外,我还没有听说过任何其他适用于 PowerShell 的 FTP 提供商。
不隶属于 StackOverflow