0
我是新来的PowerShell脚本,我需要编写一个脚本来得到一个网页的内容,如果内容不是“它工作”,以重新启动服务。PowerShell脚本用于阅读网站的内容和重新启动服务
这是我的代码如下所示:
$WebResponse= Invoke-WebRequest https://webpage.phpenter code here
$WebResponse.Content
$service = 'Service'
$logoutput = 'service restarted'
$Date = Get-Date
If ($WebResponse.Content -eq "It Works") {
Write-Host "OK"
}
Else {
Restart-Service $service -Force
}
好了,有什么问题..? – Sean
该脚本不起作用,它每次都重新启动服务,它忽略了“It works”内容。所以我做错了什么,我需要帮助 – Leibovici
你肯定'Content'只包含字符串“这工作”? – Sean