Unexpected token in expression

Welcome Forums General PowerShell Q&A Unexpected token in expression

Viewing 2 reply threads
  • Author
    Posts
    • #274431
      Participant
      Topics: 3
      Replies: 4
      Points: 51
      Rank: Member

      Hi, i run this script for updating ilo firmware, i test all strings one by one and in last string Import-Csv i get unexptected error.
      Please help to understand where i did mustake.

      Original script was taken from here:https://blog.jbgeek.net/2020/09/18/updating-the-firmware-of-a-list-of-hpe-ilo-4-ips-via-powershell/

    • #274443
      Participant
      Topics: 1
      Replies: 59
      Points: 583
      Helping Hand
      Rank: Major Contributor

      Hello Emil,

      The error you are getting is because you do not have a line termination in the foreach loop on line #24.

      You need to separate statements using semicolon (;), so your line #24 would look like this:

      Import-Csv $ILOlist | Foreach { $iloip = $_.iloip; $args = " firmwareupdate http://" + $iisip + "/" + $binname + " --url " + $iloip + " -u " + $username + " -p " + $password; Start-Process -Wait -Filepath $ILOrest -ArgumentList $args }

      Actually those 3 statements can be combined in one but I’ll leave it up to you to refactor script whenever you feel like it.

      Hope that helps.

    • #274524
      Participant
      Topics: 3
      Replies: 4
      Points: 51
      Rank: Member

      Thank you Andy!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.