我有一个检查脚本,我将其转换为输出为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 ""
由于
答案 0 :(得分:0)
将表达式包含在here-string中,以便在添加到stirng之前执行。实施例
$html = $html + @"
$(websitecheck "http://www.website01.com")
$(websitecheck "http://www.website02.com")
"@