我想写一个powershell脚本,它将根据当前目录设置下载目录变量,并将文件下载到该目录。Powershell下载文件无法正常工作
我的代码是:
cd downloads
$DevDownloadDirectory = [IO.Directory]::GetCurrentDirectory
$clnt = New-Object System.Net.WebClient
# download and extract the file
$url = “fileurl/file.zip"
$file = "$DevDownloadDirectory\file.zip"
$clnt.DownloadFile($url,$file)
我得到的问题是,每当我得到的这部分代码就泵出:
异常调用“DownloadFile”与“2”参数:“在WebClient请求期间发生异常 。”在C:\目录\ script.ps1:462 字符:20
- $ clnt.DownloadFile < < < <($网址,$文件)
- CategoryInfo:NotSpecified:(:) [],MethodInvocationException
- FullyQualifiedErrorId:DotNetMethodException
任何人都可以请帮我找出为什么发生这种情况?
这里有什么帮助吗? http://stillpearling.blogspot.com/2009/02/more-powershell-adventures.html – Shoban 2010-11-14 04:25:05
注意不正确的引用符号在行上:'$ url =“' – cederlof 2015-11-20 14:35:56