0

我有一个检查脚本,我将其转换为输出为 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 ""

谢谢

4

1 回答 1

0

将您的表达式包装在 here-string 中,以便它们在添加到搅拌之前执行。前任。

$html = $html + @"
$(websitecheck "http://www.website01.com")
$(websitecheck "http://www.website02.com")
"@
于 2013-05-21T13:22:05.650 回答