Author Posts

April 18, 2016 at 8:31 am

I had perfectly running code before updating to 5.0 for crystal reports. Now, some of my lines are giving me error.
For instance

$report = New-Object CrystalDecisions.CrystalReports.Engine.ReportDocument
# Open Weekly Sales Order Totals... report

# Update all the tables
foreach($Table in $report.Database.Tables)
  Write-host "location:$($table.location)"

I get foreach($Table in $report.Database.Tables)
Missing statement body in foreach loop

Other thing is property ServerName cannot be found on this object.

April 18, 2016 at 9:23 am

Hmm... the code you've pasted here shouldn't be giving that error, unless maybe there's some unprintable character between the "foreach($Table in $report.Database.Tables)" part and the opening curly brace on the next line. Try highlighting the closing parenthesis and the opening curly brace on the next line, deleting that, and retyping that bit, see if it helps.

April 18, 2016 at 9:51 am

You're sure you're running the powershell with admin rights ?

Whats the execution policy ?

can you highlight just the first lines and run them, not the foreach section. Does that work correctly ?

April 18, 2016 at 10:33 am

I have changed the execution policy to 'Unrestricted'. By the way, I have updated to Windows 10 and it comes with PowerShell 5.0.
I am also getting errors when I try to login to the website. I used to run this code on a daily basis. No mistakes before. The errors that I am getting for the code below
HRESULT : 0x800A01B6
$ie.Document.getElementById("js-username").value= "username"

HRESULT : 0x800A01B6

# Initiate an internet explorer object
$ie = New-Object -com InternetExplorer.Application
$ie.Visible  = $True
$url = "https://"
while($ie.busy){Start-Sleep 1}

# Enter login information
$ie.Document.getElementById("js-username").value= "username"
$ie.Document.getElementById("password_field").value = "password"


April 18, 2016 at 11:28 am

If you do this:

$ie.Document | Get-Member -Name getElementById

Do you get anything back? It looks like there's no method present with the name getElementById on your code.

April 18, 2016 at 12:16 pm

Yes, I do get back the member type and the definition

November 21, 2017 at 10:58 pm

From what I understand... Internet Explorer has elevated security controls in Windows 10. The solution is to use "IHTMLDocument3_getElementById", "IHTMLDocument3_getElementsByName" or "IHTMLDocument3_getElementsByTagName" instead. Although these methods aren't as straight forward when interacting with elements that are linked to Java script..

November 22, 2017 at 5:03 pm

On a hunch, are you pasting these scripts into the console?