0

I have been trying to get this to work via a game control panel TCAdmin.

$ModPg1 = Invoke-WebRequest "http://steamcommunity.com/sharedfiles/filedetails/?id=731604991"

$ModVer1 = ($ModPg1.ParsedHtml.getElementsByTagName('div') | Where{ $_.className -eq 'detailsStatRight' } ).innerText | Select -Last 1

If I run this cmdlet via a program like TCAdmin (or task scheduler), I get the following error....

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.

Explorer is installed, and set up. The script works just fine if I run it manually.

My guess is there is a way to get TCAdmin to run the scripts the same way I would as a windows User.

Cant find a way nearly as simple to scrape the info 'm looking for.

2
  • 1
    And what happens if you follow the advice from the error message and use the -UseBasicParsing switch parameter? Commented Jan 16, 2018 at 5:48
  • If i use Basic parsing, ".ParsedHtml.getElementsByTagName" this no longer works. Commented Jan 17, 2018 at 14:46

1 Answer 1

1

As for this...

get TCAdmin to run the scripts the same way I would as a windows User.

For any app to run as a user, that users profile must be used on the host where the code is to be run. You cannot natively run PoSH on a host as another user context. This is not a PoSH issue, it is a Windows User Principal security boundary. There are tools that let you do this. For example SysInternal PSExec and AutoIT. Yet as stated that error is pretty specific. The user profile for Internet Explorer has not been created and that only happens when you use IE at least once.

So, as Adam points, out, use the setting the error message states to use or use your code to start IE at least once.

$SomeUrl = 'https://stackoverflow.com' 
$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate($SomeUrl)
while ($ie.Busy -eq $true) { Start-Sleep -Seconds 1 } # Wait for IE to settle.

Again, if trying to run this in the context of another user, the two above tools will get you there, but you still have to fire up IE to have a profile for it.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you SO much for the quick response!! I tried to up-vote your answer but I am still in Noob status. Also your 100% correct as the issue was windows user permissions. Although the solution was much simpler than I thought. I had considered trying to find a way to parse that info with out using "ParsedHtml" (using the -usebasicparsing parameter), but I was able to find a way to get TCAdmin to run the scripts under a profile that has access to the " Internet Explorer engine ". They now run with no issues from the terminal, or the Web Panel. Thanks again for the Response!!
No worries. Glad it worked out. You'll want to mark this as answered even though you are not yet in the queue for upvoting. 8}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.