最近升級到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