Some of my script not working after updating to PowerShell 5.0

This topic contains 5 replies, has 4 voices, and was last updated by Profile photo of Korhan Tezel Korhan Tezel 5 months, 1 week ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #37937
    Profile photo of Korhan Tezel
    Korhan Tezel
    Participant

    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
    $report.Load('C:\Users\.....\....\......XXXX.rpt')
    
    # Update all the tables
    foreach($Table in $report.Database.Tables)
    {
      $table
      $tli=$Table.LogonInfo
      $li=$tli.ConnectionInfo
      Write-host "location:$($table.location)"
      $li.ServerName=""
      $liDatabaseName=""
      $li.UserID=""
      $li.Password=""
      $Table.ApplyLogOnInfo($tli)
      
      $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.

    #37942
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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.

    #37953
    Profile photo of Arie H
    Arie H
    Participant

    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 ?

    #37954
    Profile photo of Korhan Tezel
    Korhan Tezel
    Participant

    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
    $ie.Document.getElementById("submit_button").Click()

    # Initiate an internet explorer object
    $ie = New-Object -com InternetExplorer.Application
    $ie.Visible  = $True
    $url = "https://"
    $ie.navigate($url)
    while($ie.busy){Start-Sleep 1}
    
    # Enter login information
    $ie.Document.getElementById("js-username").value= "username"
    $ie.Document.getElementById("password_field").value = "password"
    
    $ie.Document.getElementById("submit_button").Click()
    
    #37956
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    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.

    #37958
    Profile photo of Korhan Tezel
    Korhan Tezel
    Participant

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

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.