最近升级到Systems Admin,我真的只是设置。我们有一个我们用来检查一些服务的powershell脚本。似乎适用于所有其他管理员。我认为这是在这个时候的权限,但想在这里查看我是否缺少任何东西。Invoke-WebRequest错误
PowerShell脚本
Import-Module WebAdministration -ErrorAction SilentlyContinue
#Change the location to match your file.
$ServerLocation = "C:\Scripts\Servers"
$StartTime = Get-Date
$ServerName = Get-Content "$ServerLocation\ServerText.txt"
ForEach ($Server in $ServerName)
{
#$Server = "ServerPD20"
#Invoke-WebRequest -Uri http://$Server/ServerService/ServerCalculator.svc | Select StatusDescription
Write-Host $Server -ForegroundColor Cyan
$Check = Invoke-WebRequest -Uri http://$Server/ServerService/ServerCalculator.svc
If($Check.StatusDescription -eq 'OK')
{
Write-Host "Server Calculator Service is:" $Check.StatusDescription
Write-Host "Status Code:" $Check.StatusCode
$Time = (Measure-Command {Invoke-WebRequest -Uri http://$Server/ServerService/ServerCalculator.svc}).TotalSeconds
Write-Host "Total Request Time: $Time seconds" `n -ForegroundColor Gray
}
ElseIf($Check.StatusDescription -ne 'OK')
{
Write-Host "Server Calculator Service is NOT ONLINE" -ForegroundColor Red
Write-Host "Status Code:" $Check.StatusCode `n
}
}
$RunTime = Get-Date
Write-Host `n"Start Time" $StartTime
Write-Host "Run Time: "$RunTime -ForegroundColor Yellow
输出我得到
Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again. At C:\Scripts\Folder\CalculatorCheck.ps1:17 char:13
+ $Check = Invoke-WebRequest -Uri http://$Server/ServerCalculator ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
+ FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
有两点需要注意。
我登录到所有四个箱子与我运行PowerShell脚本相同的帐户。我正确点击并以其他用户身份运行。我输入的用户名是我登录到所有4台服务器并确保IE已打开。
如果我在“$ Check = Invoke-WebRequest -Uri http://$Server/ServerService/ServerCalculator.svc”之后添加-UseBasicParsing,我可以获得我正在寻找的响应。但我仍然收到错误IE第一次启动。
任何想法?
谢谢!
http://wahlnetwork.com/2015/11/17/solving-the-first-launch-configuration-error-with-owowhells-invoke-webrequest-cmdlet/ – Aravinda
https://stackoverflow.com/questions/ 38005341/-response-content-can-the-parsed-the-internet-explorer-engine-is-no – Aravinda