Adding multiple lines inside french brackets to action multiple tasks

Welcome Forums General PowerShell Q&A Adding multiple lines inside french brackets to action multiple tasks

Viewing 3 reply threads
  • Author
    Posts
    • #213273
      Participant
      Topics: 12
      Replies: 11
      Points: 156
      Rank: Participant

      Hello All,

      Is it possible include multiple tasks in the IF loop for example say after echoeing “computer name found” then I want to run get-hotfix and write a message on screen to say searching for hotfixes,

      $testConnection = Test-Connection $computername
      IF ($testConnection = “True”)
      {Write-Host “$computername found” }

      }
      Else

    • #213276
      Participant
      Topics: 4
      Replies: 2247
      Points: 5,484
      Helping Hand
      Rank: Community MVP

      Is it possible include multiple tasks in the IF loop …

      Would it hurt you when you tried? What could happen? Did you try to search for it?

      BTW: Usually your code should look like this:

      IF (Test-Connection $computername ) {
          "$computername online" 
      }

      The “=” is the assign operator not a comparison operator. That would be “-eq” and you don’t compare to “True” you’d compare to $true. 😉

      Please start by learning the very basics of Powershell first.

    • #213300
      js
      Participant
      Topics: 29
      Replies: 813
      Points: 2,450
      Helping Hand
      Rank: Community Hero

      “French brackets”. I like it.

    • #213306
      Participant
      Topics: 24
      Replies: 173
      Points: 564
      Helping Hand
      Rank: Major Contributor

      Short answer, “Yes”

       

      long answer, study the output of get-help about_if

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