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
Olaf
March 30, 2020, 7:18am
2
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.
js2010
March 30, 2020, 8:19am
3
“French brackets”. I like it.
Short answer, “Yes”
long answer, study the output of get-help about_if