powershell脚本,用于搜索和复制https站点上链接的文件

时间:2016-04-08 23:35:21

标签: powershell https httpwebrequest

如何修改我的脚本以在https上搜索文件?

$source = "https://mysite/searchfolder"
$destination = "\\Transfer"

$searchFiles = Import-CSV 'C:\Users\user1\Desktop\test2.csv' -Header ("filename")

ForEach($File in $searchFiles) 
{
    Get-ChildItem -Path $source | Where-Object { $_.Name -match $File.filename } | Copy-Item -Destination $destination    
}

此脚本提供错误

Get-ChildItem : Cannot find drive. A drive with the name 'https' does not exist.

我一直在读,我可能需要使用Invoke-WebRequest,但我不确定如何将其构建到我的脚本中。任何指针都会受到赞赏。

1 个答案:

答案 0 :(得分:1)

如果您的服务器未将服务公开给列表目录,则无法在https上搜索文件。您将找不到该cmdlet,也无法使用其他编程语言。