我有一个检查脚本,我将其转换为输出为 HTML。
它具有检查网站响应时间的功能。我一辈子都无法获得以 HTML 格式显示的输出。有任何想法吗?
# Function to check external website content
function websitecheck($object) {
$webClient = new-object System.Net.WebClient
$webClient.Headers.Add("user-agent", "PowerShell Script")
$output = ""
$startTime = get-date
$output = $webClient.DownloadString($object)
$endTime = get-date
if ($output -like "*Test*" -or "*Testing*") {
"Success`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" + "`t" + $object
}
else {
"Fail`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" + "`t" + $object
}
}
#External Website Check Function
Write-Host "External Website Checks"
Write-Host ""
$html = $html + @"
websitecheck "http://www.website01.com"
websitecheck "http://www.website02.com"
"@
Write-Host "========================="
Write-Host ""
谢谢