如何检查网站/URL列表的状态?(使用powershell脚本)
我想一次获取多个URL的http状态以准备报告。如何使用powershell实现这一目标?我看到过关于通过windows机器监控多个网站的问题。我的朋友想检查200个URL的状态,他以前是手工操作的。我写了一个powershell脚本来解决这个问题。为了所有用户的利益发布它 将以下代码另存为D:\MonitorWeb中的AnyName.ps1文件\ 将包含URL列表的文件URLList.txt放在同一目录D:\MonitorWeb中\ e、 g: 现在打开普通命令提示符并导航到D:\MonitorWeb\并键入以下命令: powershell-executionpolicy bypass-文件。\AnyName.ps1 您将得到如下输出: HTTP状态200=OK 注: 这也适用于power shell版本2如何检查网站/URL列表的状态?(使用powershell脚本),powershell,monitoring,webrequest,invoke-webrequest,Powershell,Monitoring,Webrequest,Invoke Webrequest,我想一次获取多个URL的http状态以准备报告。如何使用powershell实现这一目标?我看到过关于通过windows机器监控多个网站的问题。我的朋友想检查200个URL的状态,他以前是手工操作的。我写了一个powershell脚本来解决这个问题。为了所有用户的利益发布它 将以下代码另存为D:\MonitorWeb中的AnyName.ps1文件\ 将包含URL列表的文件URLList.txt放在同一目录D:\MonitorWeb中\ e、 g: 现在打开普通命令提示符并导航到D:\Monito
即使您支持proxy,也可以使用默认的proxy设置因为StackOverflow不是一个博客网站,所以我投票将这个问题作为离题题题来结束。这里没有人们可以回答的问题。虽然你可能会在网络上找到其他类似的帖子,但这并不是什么值得鼓励的事情。如果你想提出一个符合普通问题标准mcve等的基于代码的问题,并用这段代码回答它,那就更好了。
#Place URL list file in the below path
$URLListFile = "D:\MonitorWeb\URLList.txt"
$URLList = Get-Content $URLListFile -ErrorAction SilentlyContinue
#For every URL in the list
Foreach($Uri in $URLList) {
try{
#For proxy systems
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
#Web request
$req = [system.Net.WebRequest]::Create($uri)
$res = $req.GetResponse()
}catch {
#Err handling
$res = $_.Exception.Response
}
$req = $null
#Getting HTTP status code
$int = [int]$res.StatusCode
#Writing on the screen
Write-Host "$int - $uri"
#Disposing response if available
if($res){
$res.Dispose()
}
}
http://www.google.com
http://google.com
http://flexboxfroggy.com
http://www.lazyquestion.com/interview-questions-and-answer/es6