Error message

Welcome Forums General PowerShell Q&A Error message

This topic contains 4 replies, has 3 voices, and was last updated by

1 year, 9 months ago.

  • Author
  • #65115

    Points: 64
    Rank: Member

    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,


  • #65128

    Points: 24
    Team Member
    Rank: Member

    Please post your script.

  • #65137

    Points: 64
    Rank: Member

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


    $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)
                $Replace = $Items -creplace("\A\d+","$Next") 
                $Read_INI = $Read_INI -replace("$Items","$Replace")
  • #65154

    Points: 0
    Rank: Member

    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

      Points: 64
      Rank: Member

      Thank you Curtis, I'll try that

The topic ‘Error message’ is closed to new replies.