测试URL有效性
方法一:
1 #禁用滚动条 2 $ProgressPreference='silentlycontinue' 3 Invoke-WebRequest "www.163.com" -UseBasicParsing
参考:http://www.pstips.net/usebasicparsing-in-invoke-webrequest.html
方法二:
1 $http = [System.Net.WebRequest]::Create('http://www.baidu.com') 2 $http.method="head" #只获取head节省时间 3 $http.GetResponse().StatusCode 4 $http.GetResponse().Close()
方法三:
1 $web = New-Object Net.WebClient 2 $web.openread("http://www.baidu.com")