Error message

This topic contains 4 replies, has 3 voices, and was last updated by  Tony Antony 9 months, 3 weeks ago.

  • Author
    Posts
  • #65115

    Tony Antony
    Participant

    I have a list of emails (about 1400), and I'm able to delete the email from the list and re-order numerically without issue for some, but when I try to delete some, it says the message below.

    Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32".

    All the emails are in the same exact format, for example, 1=1. How would I fix this?

    Thank you,

    Tony

  • #65128

    Daniel Krebs
    Moderator

    Please post your script.

  • #65137

    Tony Antony
    Participant

    Its' about 230 lines, but this is where the trouble is

    $Look_UP

    $Look_UP = $Read_INI[$Start..$Calender_End]
    
            $Find = $Read_INI[$Calender_Start..$Calender_End] -cmatch "^\d+=$User_Index$"
            $Next = [int]$Find.Split("=")[0] - 1
    
            foreach ($Items in $Look_UP)
            {
                $Next++                
                $Replace = $Items -creplace("\A\d+","$Next") 
                $Read_INI = $Read_INI -replace("$Items","$Replace")
            }
  • #65154

    Curtis Smith
    Participant

    It's a guess based on the little bit of information provide, but I would suspect the problem is either your $start or $calender_end variables. Based on the error message, one or both of them are system object, not integers, and to get positions in an array the was you are doing here, the $start and $calender_end variables have to be integers.

    $Look_UP = $Read_INI[$Start..$Calender_End]

    You can check their type by doing:

    get-member -inputobject $start
    get-member -inputobject $calender_end

    • #65164

      Tony Antony
      Participant

      Thank you Curtis, I'll try that

You must be logged in to reply to this topic.