前提・実現したいこと
PowerShellでサイト上のzipファイルをダウンロード、解凍したい。
発生している問題・エラーメッセージ
"2" 個の引数を指定して "DownloadFile" を呼び出し中に例外が発生しました: "リモート名を解決できませんでした。: 'www.zabbi
x.com'"
発生場所 C:\Users\A01ope\Desktop\ZabbixAgent_ver4.0.7.ps1:62 文字:1
- $cli.DownloadFile($uri, (Join-Path "C:\zabbix" $file))
-
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : WebException
※
該当のソースコード
フォルダ作成
New-Item <生成フォルダ> -ItemType Directory
WebClient 生成
$cli = New-Object System.Net.WebClient
プロキシ設定
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyServer -PropertyType String -Value http://<IPアドレス>:8080 -Force
対象URL
$uri = New-Object System.Uri(<ZipファイルのあるURL>)
保存時のファイル名を取得
$file = Split-Path $uri.AbsolutePath -Leaf
ダウンロード
$cli.DownloadFile($uri, (Join-Path <フォルダ> $file))
プロキシ無効化
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyServer -PropertyType String -Value _ -Force
試したこと
Tls12を設定したりしましたが、違うようです……。
機器によってできるものとできないものがあるようです。
補足情報(FW/ツールのバージョンなど)
・ログをとると、'www.zabbix.com'がどうしてか改行されいます。
・リモート接続使用
・OSはWindows2012R2
・入れたいzipファイルはZabbix4.0.7
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/31 02:33 編集
2019/05/31 02:37
2019/05/31 02:39
2019/05/31 02:50
2019/05/31 02:54
2019/05/31 04:31