none
How to code this powershell? RRS feed

  • Question

  • Referring to following link, I would like to know on what cause error on connection using powershell script.

    	$clnt = new-object System.Net.WebClient
    	[Net.ServicePointManager]::SecurityProtocol = 'Tls12'
    	$url = "http://www.ha.org.hk/opendata/aed/aedwtdata-tc.xlsx"
    	$file = "D:\temp.xlsx"
    	$request = [System.Net.WebRequest]::Create($url)
    	$request.Method = 'HEAD'
    	$response = $request.GetResponse()
    	$httpStatus = $response.StatusCode
    	$urlIsValid = ($httpStatus -eq 'OK')
    	$tryError = $null
    	$response.Close()
    	$clnt.DownloadFile($url,$file)

    Does anyone have any suggestions?
    Thanks in advance for any suggestions


    Thanks in advance for any suggestions


    Monday, January 27, 2020 1:09 PM

Answers

All replies