我正在尝试设置下载需要的文件来自动化和安装过程。我每次运行脚本时都会遇到错误,并且从周日开始我已经更改了七种方式,但它仍然给我错误。
脚本是:
if (test-path $java_path)
{
Write-Output "Java already installed. Skipping script"
exit 0
}
else
{
$source = "http://our.server.com/java-installer.zip"
$destination = "c:\CHPACS"
$client = new-object System.Net.WebClient
$client.DownloadFile($source, $destination)
}
我收到的错误消息是
Exception calling "DownloadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At C:\ps_script\testjava.ps1:41 char:31
+ $client.DownloadFile <<<< ($source, $destination)
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : DotNetMethodException
我是否需要创建一个函数才能使其正常工作?
谢谢: